• Create Account

# the plane and axes.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

11 replies to this topic

### #1giugio  Members   -  Reputation: 243

Like
0Likes
Like

Posted 21 March 2012 - 10:37 AM

the plane and axes.
I have some points that lie in a plane.
I have a trasformation matrix that rotate these points and the plane.
these points are 2d points with a 0 in z component.
I must calculate the 2d rotation on the the plane from 2 points before and after the trasformation with an arctan2 or wih some other methods.
The problem is that the rotation may be in xy plane or in yz plane or in xz plane.
Naturally if i'm in xy plane i must take the xy coords, if i'm in xz plane i must take xz coords.

Is possible from a plane extract what are the coords to consider?
how?

thanks.

### #2previlo  Members   -  Reputation: 102

Like
0Likes
Like

Posted 21 March 2012 - 04:26 PM

You could get the information, whether your plane is in xy, xz or yz, from the normal of the plane, if that's what you're asking for.
Suppose you have the plane equation: ax+by+cz+d=0, where (a,b,c) is the normalized plane normal, and d is the nearest distance from the plane to the origin.

You then might want to check the normal ( a,b,c ).
E.g.:
if ( fabs( fabs( a ) - 1.0f) < EPS ) then plane is in yz
if ( fabs( fabs( b ) - 1.0f) < EPS ) then plane is in xz
if ( fabs( fabs( c ) - 1.0f) < EPS ) then plane is in xy

Hope that helps.

### #3giugio  Members   -  Reputation: 243

Like
0Likes
Like

Posted 22 March 2012 - 11:31 AM

I see the formula, but what is EPS? a small value?

because i have this normalized normal:


Normal = {0; -0.8;-05}



with your formula i can't find any plane if EPS is = 0.0001 for example.

Where i'm wrong?
I wish understand more , where is the d (distance from the origin), and how i can calculate it?

I sorry for my english.

very thanks.

### #4previlo  Members   -  Reputation: 102

Like
1Likes
Like

Posted 22 March 2012 - 03:36 PM

Yes, EPS is supposed to be a very small value greater than zero: e.g. 10^-6 = 0.000001
A bigger value is also sufficient in your case.

First, I fear your normal is not normalized. A normalized normal should have a length of 1.
When you compute the length of your normal you get:

length( normal ) = length ( {0,-0.8;-0.5} ) = sqrt( 0 + 0.64 + 0.25 ) = sqrt ( 0.89 ) < 1

,so you need to normalize your normal like:

normal.x /= length(normal)
normal.y /= length(normal)
normal.z /= length(normal)

( though checking for zero, not dividing by zero )

When you then have the normalized normal of your plane, you need at least one additional point on the plane.
And you said you have a bunch of points sitting in the plane.

Just take one, say p.
Now compute d of the plane equation like: (scalar product of normal with p)

d = normal.x*p.x + normal.y*p.y + normal.z*p.z

then you have all you need:

a = normal.x
b = normal.y
c = normal.z

then you have your plane eq.

a*x + b*y + c*z + d = 0

All x,y,z for which this equation is true, is sitting on this plane as well.
So, if your a,b,c and d are correct you can test your plane equation with your point p, which you took for computing the distance d.

### #5giugio  Members   -  Reputation: 243

Like
0Likes
Like

Posted 27 March 2012 - 03:15 AM

very thanks.
Sorry for my english an my ignorance in mathematics.
but how is related the distance d with the planes in that i is?
recapping:
i have the plane equation:

d = normal.x*p.x + normal.y*p.y + normal.z*p.z


i have the normal of the plane
i have the point
after calculating :
i have the normal and the point p then i can extract d:

d = normal.x*p.x + normal.y*p.y + normal.z*p.z


now i have d for a point and a normal, the normal is the same for all the points in the plane.
but how d is related with the plane in which are?
what is the geometric represetation of this equation ?
how i can visualizing this?

if ( fabs( fabs( a ) - 1.0f) < EPS ) then plane is in yz
if ( fabs( fabs( b ) - 1.0f) < EPS ) then plane is in xz
if ( fabs( fabs( c ) - 1.0f) < EPS ) then plane is in xy

and where is d in these equations?

### #6giugio  Members   -  Reputation: 243

Like
0Likes
Like

Posted 28 March 2012 - 03:43 AM

Thanks I went ahead to thinking .
I'm read on 3d math primer for graphics ... the plane equation.
but my problems are
1)A plane can be not aligned to any axis?
2)
I have
a = normal.x
b = normal.y
c = normal.z

the d calculated with a point

a*x + b*y + c*z + d = 0

what i must substitute and calculate in this equation?

set the value of y
set the value of z
and calculate the x ?
...
set the value of y
set the value of x
and calculate the z ?
....
ecc...

is this the method?

I'm sorry but i'm a newbe in math
thanks.

### #7pilarsor  Members   -  Reputation: 130

Like
0Likes
Like

Posted 28 March 2012 - 01:56 PM

You calculate a,b,c,d and substitute x,y,z with the values you want to check.

### #8giugio  Members   -  Reputation: 243

Like
0Likes
Like

Posted 30 March 2012 - 03:35 AM

thanks, i understand.
I calculate from the normal vector and the first point, the distance, then i substitute the point with 0 0 1 (x axis) or 0 1 0(y axis) ecc.....
All works fine, the problem is that i can have for example a normal like 0 0,7 0,7(from a rotation of 45°) in this case the plane's function is 0 only for an axis , in this case i think that i must project an axis into another for find the x/y(in two dimension) coords and test the angle of rotation with for example atan2(y',x') - atan2(y,x) where y' x' and x y are the coords of the same point before and after i apply the rotation matrix.
Is correct do the projection?
I read that the projection is a reduction operation then i can find the values always in 2 dimension then apply the atan2 for find the correct angle of rotation on the axis.

but how?

very thanks.

### #9pilarsor  Members   -  Reputation: 130

Like
0Likes
Like

Posted 30 March 2012 - 04:14 AM

Actually, you need to plugin position vectors to x,y,z in the same coordinate system your plane is defined, not directional vectors as you did with (0,0,1) and (0,1,0).

But I'm not sure what you're actually looking for... maybe you can clarify a bit more, what information you actually have given, and what you need to calculate.

Thanks.

### #10giugio  Members   -  Reputation: 243

Like
0Likes
Like

Posted 30 March 2012 - 08:12 AM

i have a rotation matrix and some points on a plane .

The rotation matrix is applied to the plane and on points.

My goal is to calculate rotation matrix on the plane with the difference from rotated plane(and rotated points multiplied for the rotation matrix) and not rotated plane, with:

angle = atan2(RotPlane'.y,RotPlane'.x)- atan2(RotPlane.y,RotPlane.x) or other methods.
where RotPlane' is the 2d rotated vector and RotPlane is the 2d non rotated vector
my problem is that the rotation matrix rotate around the center of profile(in the normal direction) but also on the x y axes.

now i find in what plane i'm ; but there is a problem with rotate plane on xy the coords for calculate the angle of rotation of the profile are not correct , see the plane rotated and normal rotated :you see that i can't calculate the angle of rotation with atan2 because the values are in 3 dimension and not in 2.

I think that i can project a coord (y for example) on the x plane and find a 2d value.

is possible?
Or, is possible to go on the plane coords and next calculate the angle , but how? multiply the xyz axis for the matrix rotation?
I'm not understand
thanks.

sorry for my english

### #11pilarsor  Members   -  Reputation: 130

Like
0Likes
Like

Posted 30 March 2012 - 09:15 AM

Thanks for the illustrations.

First, if you want to compute a rotation matrix, that rotates points around the center of profile inside that plane, I would suggest, that you create a quaternion from an
axis, angle representation.
The axis of rotation you already have defined by your plane's normal vector.
The angle you can compute like the following ( using 3D coordinates ):

vec3 v0 = RotPlane - centerOfProfile;
vec3 v1 = RotPlane' - centerOfProfile;
v0.normalize();
v1.normalize();
float angle = acosf( dotProd<v0,v1> ); ( = acosf( v0.x*v0.x + v1.x*v1.x ) )

Now, generate your quaternion q by: ( axis needs to be normalized )

q.x = axis.x * sinf( angle / 2 );
q.y = axis.y * sinf( angle / 2 );
q.z = axis.z * sinf( angle / 2 );
q.w = cosf( angle / 2 )

If you want a matrix representation from q, just use a standard method for converting from normalized quaternion to a rotation matrix.

Btw... if you just want the angle to apply in one of your predefined axis aligned planes xy,xz or yz, just leave out the whole quaterion step.
Here you can just generate a standard 2d rotation matrix using sin and cos from that angle.

### #12giugio  Members   -  Reputation: 243

Like
0Likes
Like

Posted 02 April 2012 - 05:06 AM

Hello.

I can have the last chance?

For me calculate the centroid is a problem, is possible to do another method?

For example:

is possible using the z,y or x axis for do the dot product with the point after the rotation and and before rotation??

then i can see where lies the plane and use the correct axis vector for do the dot product.

and...
I'm trying to see where the planes lie, for my profile points and rotation matrixes (a test)but i have some problem , this is my code:

double drot = DEG_RAD(45);

//rotation matrixes about x,y,z
//C3DVectorIfc vx(1.0, 0.0, 0.0);
//C3DVectorIfc vy(0.0, cos(drot), -sin(drot));
//C3DVectorIfc vz(0.0, sin(drot), cos(drot));

//C3DVectorIfc vx(cos(drot), -sin(drot), 0.0);
//C3DVectorIfc vy(sin(drot), cos(drot), 0.0);
//C3DVectorIfc vz(0.0, 0.0, 1.0);

C3DVectorIfc vx(cos(drot), 0.0, sin(drot));
C3DVectorIfc vy(0.0, 1.0, 0.0);
C3DVectorIfc vz(-sin(drot), 0, cos(drot));
//create rotation matrix
C3DMatrixIfc mxRotD;
mxRotD.m_X = vx;
mxRotD.m_Y = vy;
mxRotD.m_Z = vz;

C3DVectorIfc* pV1 = pProfile[0].get();
C3DVectorIfc* pV2 = pProfile[1].get();
C3DVectorIfc* pV3 = pProfile[2].get();
C3DVectorIfc* pV4 = pProfile[11].get();

C3DVectorIfc vEdge1 = (*pV2)-(*pV1);
C3DVectorIfc vEdge2 = (*pV2)-(*pV3);

//find the normal
C3DVectorIfc pVNormal = vEdge1^vEdge2  ;

pVNormal = pVNormal.Normalize();

double distancex =     fabs(pVNormal.x * pV4->x   pVNormal.y * pV4->y   pVNormal.z * pV4->z) ;

//axis in plane coordinates
C3DVectorIfc axisX = mxRotD.Tras() * C3DVectorIfc(1.0, 0.0, 0.0);
C3DVectorIfc axisY = mxRotD.Tras() * C3DVectorIfc(0.0, 1.0, 0.0);
C3DVectorIfc axisZ = mxRotD.Tras() * C3DVectorIfc(0.0, 0.0, 1.0);

bool isX = false;
bool isZ = false;
bool isY = false;
double d1 = fabs((pVNormal.x * axisX.x   pVNormal.y * axisX.y   pVNormal.z * axisX.z)   distancex);
double d2 = fabs((pVNormal.x * axisY.x   pVNormal.y * axisY.y   pVNormal.z * axisY.z)   distancex);
double d3 = fabs((pVNormal.x * axisZ.x   pVNormal.y * axisZ.y   pVNormal.z * axisZ.z)   distancex);
//dtest is always ok
double dTest = fabs((pVNormal.x * pV1->x   pVNormal.y * pV1->y   pVNormal.z * pV1->z)   d1);

if(fabs(fabs(d1)) < 1e-3)
isX = true;//true for x and z rotation
if(fabs(fabs(d2)) < 1e-3)
isY = true;//true for y rotation
if(fabs(fabs(d3)) < 1e-3)
isZ = true;//alwais false

where is the mistakes?


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS