#### Archived

This topic is now archived and is closed to further replies.

# MATH!! NOOOOO!

This topic is 6717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hehehheehee Ok, I''ve got a math question for you all. I''ve got two points. Now, I''m wanting to know the arc of the line. How would I do that? Thanks! Justin Eslinger

##### Share on other sites
Do you mean the slope of the line between the points or the arc. If you want to find the arc, then you need to have more than just two points mathwise.

Shiztag

##### Share on other sites
Well, I''m making an editor for my game. And I need degrees to rotate this object. In my editor, all you have to do is move the points to rotate the object. Does that make sense?
heehe

Justin Eslinger

##### Share on other sites
So, you''re moving from one point to another point, but you''re doing it with respect to the center of the object that you''re rotating, right?

In any case, to rotate the object i think you''d need to know the center of rotation, and the initial and final points.

Shiztag

##### Share on other sites
You got it! So how would I got about doing it?

##### Share on other sites
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

##### Share on other sites
Oops, I guess it wouldn''t really make a difference if the points weren''t the same distance from the center. Actually, it''s a lot easier if they''re not.

Shiztag

##### Share on other sites
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.

##### Share on other sites
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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633294
• Total Posts
3011241
• ### Who's Online (See full list)

There are no registered users currently online

×