I’m trying to place two objects next to each other with the tip of each object connecting with the other.
I have been able to do this when the second object is rotated to the right on the y-axis because the tip of that object is always the min value of a bounding box. When the object is rotated to the left on the y-axis the tip of that object is somewhere along the x-axis. The information that I have is the x and y-axis of the bounding box, as well as the dimensions of the trapezoid/object.
Does anyone know how I can calculate this?
An image for clarification:
I have found a post on math stackexchange (https://stackoverflow.com/questions/9971230/calculate-rotated-rectangle-size-from-known-bounding-box-coordinates) which seemed at first to be of help, but the results of my calculations are always absurd and cannot be right so I’m probably doing something wrong or looking in the wrong direction.
Any tips are welcome!
Any chance to provide an editable live code example, showing how you build this trapezoid, and provide explanatory pics with what you have and what you try to achieve?
I made a fiddle with the code I use to make these objects, but keep in mind that in my ‘real’ code the object can change in dimensions and the cut can vary in angle.
EDIT: My code starts at line 563, above that is just the CSG library
I also made some screenshots to show what I have, the first three screenshots are what is working fine (when the angle is 90 degrees or less) and the fourth is when it stops working like I want it to, but that is because my code is not subtracting the position of the corner on the bottom that I am trying to calculate.
Does no one have any idea? Still struggling with this…
Find the point with max Z in world coordinantes, then find the vector between this point and the point where you want to place the object, add this vector to position of the object.
That seems like it should work, thanks I’m going to try that out!