bezierjs
bezierjs copied to clipboard
Rotational extents would be incredibly handy
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.
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)
Hi, thanks for getting back to me.
No problem, I'm attaching an image.
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.
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](https://user-images.githubusercontent.com/177243/120952706-731add80-c700-11eb-8256-e2c04ffffecc.png)
Getting your angles is then a matter of evaluating the angles to each curve's "left" and "right" extrema.
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.
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)
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.
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.: