Notifications
Clear all

[Closed] Find missing angle

This one has stumped me, It’s kinda hard to explain without a diagram.

I need to find the angle required to rotate the Blue Point3 around the Green matrix3 until the purple line is directly above the Red Point3 in the Y direction in the green coord space

I hope that makes sense!

Any tips no mtter how small would be much appreciated.

Rhys.

5 Replies
 eek

Project the green point and red point in world space onto the grid below and find the dot product between them? Then convert this into percentials for the blue point?

This won’t work because the green transform could be at any angle. not just like in the picture.

I think what I need to do somehow is to take the Y value of the red point in context of the green coordsys then move it using a preTranslate so it’s on the same plane as the blue point.

Then I can just dot product the points to get an angle.

my problem is, I can’t figure out “to take the Y value of the red point in context of the green coordsys”

1 Reply
 eek
(@eek)
Joined: 11 months ago

Posts: 0

umm…
tm = (blue.transform * inverse green.transform)
red.transform.pos.y = (tm * green.transform).pos.y

You said yourself that the green point defines a coordinate system. We want the purple line to be rotated inside the XY plane (the circle) about the Z axis so that it matches the projection of the vector connecting the green and the red points in that same XY plane, right?

Transform the red point into the green coordinate system. (Just multiply the red’s position by the inverse of the matrix3 of the green’s transform and you will be in local space of the green point). So assuming that the Z of this coordinate system is the vector perpendicular to the circle, you can easily get the Z distance in local space from the red point to the XY plane of your custom coordinate system – it is the Z component of the red point’s position when transformed into that space, taken with negative sign.

Knowing this, you can take the Z normal vector of the coordinate system IN WORLD SPACE (.row3 of the matrix3), multiply by the Z distance in local space you found in the previous step, add the result to the red point in WORLD SPACE and you will end up at a world space point which will be on the XY plane of the custom coordinate system defined by the circle. That’s the projection of the red onto the XY of the green.

Now connect the green point with this new point and you will have the vector defining the other arm of the angle you are looking for. Normalize both the Green->Blue and Green->ProjectionOfRed vectors, get acos of their dot product and you will have the angle.

Thankyou very much Bobo and Charles. I was very close!

I had forgotten to multiply the red point by the INVERSE which was messing me up.

Bobo;
Great explanation. Thanks again.
It looks like I really need to buy your matrix DVD.

Rhys.