phetsims / kite

A library for creating, manipulating and displaying 2D shapes in JavaScript.
http://scenerystack.org/
MIT License
15 stars 6 forks source link

add CAG (Constructive Area Geometry) support #30

Open pixelzoom opened 11 years ago

pixelzoom commented 11 years ago

This could be used immediately in graphing-lines.

jonathanolson commented 11 years ago

See details in https://github.com/phetsims/kite/issues/20

Also necessary for more advanced BAM 3D edge cases, and for WebGL work.

pixelzoom commented 11 years ago

Another request for this feature. In ph-scale, I have all kinds of odd shapes that I need to draw. They would be trivial with CAG. They are going to take more time without CAG, and will require copying more code from kite (eg, rounded corners).

pixelzoom commented 10 years ago

Another need for this feature today, in sun.ComboBox. Request to add a rectangle behind the arrow button, which would have square corners on left end, round corners on right end.

pixelzoom commented 10 years ago

Another need for this feature today in pH Scale, yet another rounded rectangle combined with another shape. I'm getting good at using Shape.arc.

pixelzoom commented 9 years ago

Removing the "high priority" label, because it's not.

jessegreenberg commented 9 years ago

This would be very helpful in Capacitor Lab, shapes in that sim were mostly put together using CAG. It is not critical though, I can still redraw shapes using arcs and z layer ordering.

jonathanolson commented 7 years ago

I've implemented the large bulk of cases for CAG (referenced some commits towards https://github.com/phetsims/kite/issues/20). shapeUnion, shapeDifference, shapeIntersection and shapeXor (methods on Shape) are implemented. getArea and similar functions came for free.

Some outlines of the general CAG process exist in https://github.com/phetsims/kite/issues/20, but this issue is more suited towards the subset that is actually completed and should be reviewed.

For review, I'd recommend:

Definitely let me know where documentation can be improved (anything that's confusing). Thanks!

Assigned to @jessegreenberg for review.

jonathanolson commented 7 years ago

I will need to implement the curvature-based discrimination of half-edges when sorting incident edges to vertices. CLB has a case with a line and arc with the same tangent.

jonathanolson commented 7 years ago

Implemented the curvature-based method described above.

Additional things added (which could benefit from review):

Extra credit: Try creating two shapes whose union either isn't correct, or asserts out!