Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / 3DMath Q Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
ljilekor

February 28, 2005, 09:27 AM

Well, the problem is hard to explain without the right terminology.


  1.  
  2. GIVEN
  3.  
  4.                 rot o A
  5.                    /
  6.                   /
  7.                  /
  8.                 /             P
  9.  ------X-------/---------------
  10.        |      /
  11.             /
  12.           - /
  13.            B
  14.  
  15. RESULT
  16.  
  17.               rot+x  o A
  18.                    //
  19.                 //
  20.              //
  21.        B  //                 P
  22.  ------X-----------------------
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  


GIVEN
- I have a line AB defined by 2 3DVec's A,B and the rotation rot(x,y,z).
- I have a 3D plane P
- the line AB intersects the plane P

RESULT
- Result is NOT *coplanar* with P. Point B is 'sitting' on P.
- Rotating around A
- 'rot' is a vec3d (x,y,z)

How much x(x,y,z) must I rotate AB around A (rot(x,y,z) representing the current rotation) to have AB 'sitting' on plane P?
|AB| doesn't change.

Ok, think this is the right way to put it.

Bless for looking at my problem.

 
Rui Martins

February 28, 2005, 09:59 AM

If your Rot is not parallel to the plane P, then you have a badlly defined problem, because you don't have a single solution, but many instead. (assuming Rot is a rotation point => 3 degrees of freedom).

Or is Rot the axis of rotation, which should pass through A ?

 
ljilekor

March 01, 2005, 04:24 AM

Ok, A has only 1 rotation axis (ortho to monitor). In this case.
Of course it must be applied in an arbitrary axis. So, if the axis has to be provided, you can consider it as a given element.

There still are 2 sollutions but I think I'll have no problems taking care of this issue.

 
Rui Martins

March 01, 2005, 09:19 AM

Well, You haven't really clarified your problem, but by reading your descriptions, I'm not sure if this is a 2D or 3D problem. You mention a plane, which could lead to 3D, but you also seem to be representing a plane with a line, and assuming it is also orthogonal to monitor as the axis. So not sure, but your post subject is 3D.

Assuming a 3D problem, and that the Rotation vector is Parallel to the plane.Here is tips for the solution.

So, to know how much to rotate, we must have a reference, and since you don't mention one, I'll define my reference, as the line perpendicular to the plane which passes through A (the plane Normal through A).

So, lets define Alfa as the angle formed on A, between the reference line and the line AB.
define Beta as the angle formed on A, between the reference line and the line AB when passing through X (lets call it AX).

So, what you need to find is (Beta-Alfa)

So we have to find the expressions for Alfa and Beta.

Cos(Alfa)*Length(AB) = Length( Projection_of_AB_over_Plane_Normal )

Projection_of_AB_over_Plane_Normal is found by doing the Cross Product, between The Normal and the Line (Vector) AB.

The Length of a vector no need to explain right !?

So, ALfa = ArcCos( Length( Projection_of_AB_over_Plane_Normal ) / Length(AB))

For Vector AX it's similar, then do Beta-Alfa do find the amount to rotate.

NOTE: AB, and AX in almost every situation won't have the same length, since AB when croosing plane on point X can be "cut" anywhere, it might not even get there if AB is too short and/or X is too far.

If the Problem is 2D, after some jugling with the Pithagoras Theorem and the Triangles formed by Line AB, Reference Line, and the plane surface line, you can get to the answer too.


 
ljilekor

March 02, 2005, 07:40 AM

GIVEN

  1.  
  2.  
  3.                rot o A
  4.                    /
  5.                   /
  6.                  /
  7.                 /
  8.                /              P
  9. ------X-------/---------------
  10.       |      /
  11.            /
  12.          - /
  13.           B
  14.  
  15. RESULT
  16.  
  17.  
  18.              rot+x  o A
  19.                    /
  20.                 /
  21.              /
  22.          /                    P
  23. ------X-----------------------
  24.  
  25.  
  26.  
  27.  
  28.  


We're in 3D

|AX| must = |AB| (AB must stay the same length)

The rotations rot and x are planar rotations on A's local (rot+x,0,0) axis. I'd rather have a general sollution on an arbitrary rotation axis relative to the world, though.

X is also a point I have to calculate.

I must find X first(there should be 2 sollutions) and then calculate Beta the way you did.

But how do I find X ???

I must rotate AB around A for x amount on A's loc x axis until AB is 'sitting' on the plane.

 
Rui Martins

March 02, 2005, 08:05 AM

... I'd rather have a general sollution on an arbitrary rotation axis relative to the world, though.


That is very easy, once you have the local rotation !
You just have to create a Matrix with the following transforms:
- Translate From LOCAL origin (C) to World Origin
- Rotate
- Translate back to C


X is also a point I have to calculate. I must find X first(there should be 2 sollutions) and then calculate Beta the way you did.

You don't have to calculate X, to find the angle to rotate AB!
But after you know the angle, you can use Point (A) and the angle and the length of AB to find X.


But how do I find X ??? I must rotate AB around A for x amount on A's loc x axis until AB is 'sitting' on the plane.


I think the previous explanation already gave you enough tips to find it out.

Some reasoning here:
- You know the length of AB
- You can Determine the distance from A to the plane
- You can project line AB into the plane, (2 constrains already solved for X)
- You can determine the Length of the previous projection into the plane.

So basicly you have all the side lengths of the triangle defined by:
- line AB (after the targeted rotation),
- distance from A to plane.
- projection of line AB on plane

Use the Pythagoras Theorem and the Internal Angles Add to 180 Degrees, and you should reach your intended result.

Resuming in simple terms:
Knowing the hipotenusa of the triangle (Length of Line AB), and one of it's sides (Distance from A to plane), you can determine Beta using the formula I mentioned before.

Then as I said before Calculate Beta-Alfa !

Remember however that if the rotation axis is not paralell with the plane, you will have to change the equation, by adding another COS(Teta) or SIN(Teta) (depending on how you measure it), on the left side of the equation.

Teta will be the angle formed between the Rotation axis and the plane, or plane normal.

 
ljilekor

March 02, 2005, 11:27 AM

Major thx, Riu

I see which in direction i have to look for the sollution...

I'm missing a few things though

-Don't see why I need the projection of AB on P. It's NOT the 3rd side of the orthotriangle (it's too short but maybe I need its orientation???).

-Do 2 lengths |AB| and |AP| define an orthotriangle? (I guess yes) But what about the angles?
"Knowing the hipotenusa of the triangle (Length of Line AB), and one of it's sides (Distance from A to plane), you can determine Beta using the formula I mentioned before." (Which one ???).

PS: It's a shame this forum doesn't support images. Me not being too familiar with the terminology, a diagram would be better than a thousand words.

 
Rui Martins

March 02, 2005, 11:48 AM

Major thx, Riu


Actually it's Rui, Not Riu, that is a Robot character from Japanese commics I believe 8)

I see which in direction i have to look for the sollution...

Great that was the ideia !

... -Don't see why I need the projection of AB on P. It's NOT the 3rd side of the orthotriangle (it's too short but maybe I need its orientation???).


Forget that if you only want the Angle of rotation, use the section I named "Resuming in Simple Terms".
That was to calculate X directly, but thinking about it, you are right, it's too short, at least in the case where AB isn't CUT, this is it stays the same length.
Actually what you should have asked was that you wanted to rotate point B using A as center, so that B layed on the Plane, Not X, that confused things.

-Do 2 lengths |AB| and |AP| define an orthotriangle? (I guess yes) But what about the angles?


A normal by definition is Orthogonal to the plane, hence it makes a 90 degree angle with it!

"Knowing the hipotenusa of the triangle (Length of Line AB), and one of it's sides (Distance from A to plane), you can determine Beta using the formula I mentioned before." (Which one ???).


Not paying much attention are you ?
One or Two posts back. Quoting
  1. Cos(Alfa)*Length(AB) = Length( Projection_of_AB_over_Plane_Normal )


PS: It's a shame this forum doesn't support images. Me not being too familiar with the terminology, a diagram would be better than a thousand words.

If you really need an image, there are sites just for that!

I believe one is called imageshack, and they are free.
Just search arround the net, and after posting the image on those sites, just post a message with a link to it, here on Flipcode.

 
This thread contains 8 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.