MATH!! NOOOOO!

Started by
7 comments, last by BlackScar 23 years, 10 months ago
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
~-=-=-=-=-=-=~~Justin Eslinger~~.."BlackScar"..~~-=-=-=-=-=-=~
Advertisement
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
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
~-=-=-=-=-=-=~~Justin Eslinger~~.."BlackScar"..~~-=-=-=-=-=-=~
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
You got it! So how would I got about doing it?
~-=-=-=-=-=-=~~Justin Eslinger~~.."BlackScar"..~~-=-=-=-=-=-=~
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.

  &nbsp.
  / / <-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
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
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.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
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.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.

This topic is closed to new replies.

Advertisement