Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotational extents would be incredibly handy #156

Open
lgpmichael2 opened this issue Jun 5, 2021 · 7 comments
Open

Rotational extents would be incredibly handy #156

lgpmichael2 opened this issue Jun 5, 2021 · 7 comments

Comments

@lgpmichael2
Copy link

Hopefully this is the correct method to suggest enhancements.

It would be incredibly handy to be able to say what the extents are of a bezier curve relative to a point.

The use case here is a line of sight system, where knowing the exact boundaries of a curve relative to a point is essential to knowing what to draw. I suspect that many people could find this useful.

Currently, I'm using multiple functions of the existing API, but that is going to be more expensive than doing it properly, as the existing API uses some iterative steps to get fine results when it only needs to know very coarse results for its own iterations.

I looked at doing it properly myself, but the maths is beyond me unfortunately.

Whether or not you feel this is a worthwhile addition to the api, I'll say thanks for what you've already produced, it's a great tool.

@Pomax
Copy link
Owner

Pomax commented Jun 6, 2021

it might be, but I must confess I'm not entirely sure what you're asking for. Can you elaborate on what you mean with "what the extents are of a bezier curve relative to a point"? (concrete use cases would probably go a long way towards helping me understand)

@lgpmichael2
Copy link
Author

Hi, thanks for getting back to me.

No problem, I'm attaching an image.

bez

If your origin is at point A, and you're trying to determine the angular extents of the three (very rough) beziers, so as to know what can be shown further from the origin in the background, the only way I can work out to do it is to widen the boundaries until I get only one intersect, or to rotate the bezier and use the inflection points at the angle of the border. Either way is iterative. I suspect that there is a better way, but, the maths of it escapes me.

Case 1 is easy, it's just the endpoints, but case 2 and case 3 are a lot less simple.

@Pomax
Copy link
Owner

Pomax commented Jun 7, 2021

hm, you could rotate-align the curve to your point A (relative to, say, the center of the bezier hull), then compute the extrema that you'd use for constructing the bbox?

Screen Shot 2021-06-06 at 7 50 09 PM

Getting your angles is then a matter of evaluating the angles to each curve's "left" and "right" extrema.

@lgpmichael2
Copy link
Author

Hi,

Yep, that was one of the options I'd considered. But it's still iterative, as if the extrema doesn't match exactly with the angle, all you can do is rotate and solve again.

Just to note: I'm not looking for help, I've solved it by moving the boundary lines until they get only one intersect (or two very close ones, depending on granularity), and the code works. I'm just trying to help with a suggestion for the library.

@Pomax
Copy link
Owner

Pomax commented Jun 8, 2021

Sure, but that includes ideating on how to do this, and capturing that ideation in the issue because if there's an easy way to do it: cool, but if not (and I'm leaning towards not), this might just be too niche to add to the library itself.

What's the use-case here? (as in, what actual thing are you doing where this need pops up)

@lgpmichael2
Copy link
Author

The use case is simply line of sight in a game system. With an environment which includes objects built with bezier curves, it's to know what needs to be clipped from drawing, what parts of a landscape can be tagged as "known" about.

The quickest solution, after trying the angle and the line iteration, seems to be iterating the angle of the border lines until you reach an acceptable level of error.

@Pomax
Copy link
Owner

Pomax commented Jun 11, 2021

yeah I'm not sure there is a way to do this without iterating. However, to make things more annoying, there's of course situations where you have multiple parts of the curve visible, e.g.:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants