🔒 Locked
MATH!! NOOOOO!
Advertisement
Original Post
Hm.. lemme think. It's been awhile since I had precal/trig.
First, it would make it a lot easier if you made both of the points that you're using an equal distance from the center.
Ok. say here's one of the points with respect to the center.
 .
/ / <-y
/ /
C---
x
Just find the inverse tangent of (y/x) and that'll give you it's angle with respect to the xy plane. Now just subtract the inverse tangent of (y-component/x-component) of the other point and you'll have the angle between the two points. I think...
So, say you had a point ((4/5),(3/5)) and a point ((sqrt(2)/2),(sqrt(2)/2). Then you'd take the inverse tan of ((3/5)/(4/5)), which is about 53, and the inverse tan of 1, which is 45 degrees. You'd subtract these two and get the angle of about 8 degrees(with more precision of course). I sure hope you wanted the angle...
Shiztag
Edited by - Shiztag on June 24, 2000 1:52:51 AM
Edited by - Shiztag on June 24, 2000 1:54:23 AM
First, it would make it a lot easier if you made both of the points that you're using an equal distance from the center.
Ok. say here's one of the points with respect to the center.
 .
/ / <-y
/ /
C---
x
Just find the inverse tangent of (y/x) and that'll give you it's angle with respect to the xy plane. Now just subtract the inverse tangent of (y-component/x-component) of the other point and you'll have the angle between the two points. I think...
So, say you had a point ((4/5),(3/5)) and a point ((sqrt(2)/2),(sqrt(2)/2). Then you'd take the inverse tan of ((3/5)/(4/5)), which is about 53, and the inverse tan of 1, which is 45 degrees. You'd subtract these two and get the angle of about 8 degrees(with more precision of course). I sure hope you wanted the angle...
Shiztag
Edited by - Shiztag on June 24, 2000 1:52:51 AM
Edited by - Shiztag on June 24, 2000 1:54:23 AM
Alright, here''s the deal:
The object has a center point. It is the selected object. Imagine a transparent sphere like a tracball enclosing the object. You move the nouse onto the object and click down. This is your first point, call it P1. You drag the maouse a little bit and unclick. This is point P2. This is just like putting your finger on the transparent sphere and spinning it like a tracball.
Here''s the math:
x and y of P1 and P2 are defined by the mouse clicks. You have to translate and scale these properly to object space.
z of P1 is the intersection of the ray originating at the object''s center and going through x and y of P1. You must solve for z by intersecting the ray with the sphere enclosing the object. Ray trace 2 rays, one for P1, and one for P2.
You now have 3 points: P1 and P2 and the object center. This is a 3 dimensional triangle. The normal of this triangle is your axis of rotation. Think about this. The angle is the acos of the dot product of the 2 unit vectors emenating from the object''s center.
The object has a center point. It is the selected object. Imagine a transparent sphere like a tracball enclosing the object. You move the nouse onto the object and click down. This is your first point, call it P1. You drag the maouse a little bit and unclick. This is point P2. This is just like putting your finger on the transparent sphere and spinning it like a tracball.
Here''s the math:
x and y of P1 and P2 are defined by the mouse clicks. You have to translate and scale these properly to object space.
z of P1 is the intersection of the ray originating at the object''s center and going through x and y of P1. You must solve for z by intersecting the ray with the sphere enclosing the object. Ray trace 2 rays, one for P1, and one for P2.
You now have 3 points: P1 and P2 and the object center. This is a 3 dimensional triangle. The normal of this triangle is your axis of rotation. Think about this. The angle is the acos of the dot product of the 2 unit vectors emenating from the object''s center.
The above also works if you want to rotate the object around an axis perpendicular to the screen. Just click the mouse outside the diameter of the sphere and drag it around in a circle. z will then evaluate to 0 and you normalize P1 and P2. You have a triangle which is coplanar to the screen, so your normal to the triangle is perpendicular to the screen, and so is your axis. Now just get the angle between the normalized vectors.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement