Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to define a polygon part in a rectangle?

JosiahMaybe

Platinum Coder
Okay so I have this 3d thing, it projects to 2d view plane via view point and XYZ view plane definition. I can define a rectangle like shape by xmin, ymin, xmax, and ymax in 2d. It may also be a point or line that rectangle like thing. What I am really trying for is approximate intersect of 2 2d shapes for 3d draw order. That rectangle like thing is common rectangle of both shapes sort of.

I know centroids, projection, intersection, inside outside algorithm for rectangle and other stuff. All points are with real, finite numbers. Polygons are not self intersecting. There may be a rectangle entirely in or out of a polygon. I handle anything in 2d collinear entirely already. What I have trouble with is like that bottom left corner of top left intersection. How to determine when to use parts of rectangle as vertices in a shape and which?

I already have a minimums and maximums at x or y intercepts with rectangle thing so I can find which side mostly on but not exactly. I know this is a mathy question. Feel free to remove it if needed. Are there any free resources on this? Thanks for whatever you may help with. Is there an existing algorithm I could study? X E.
 

Attachments

  • Screenshot_20240811-195557.png
    Screenshot_20240811-195557.png
    116.7 KB · Views: 1
Okay, solved I guess, like have 4 points, one for mins, two min max, and one maxes, get bounds inside rectangle, if a point outside rectangle is more in a way from center of rectangle move toward it as much as is in bounds of rectangle. If a line intersects x or y like that, move toward intersect like that. Should give an accurate 2d approximation. X E.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom