inline bool CPlane::IsSlanted()
{
if(n.x == 0) //no divide by zero
return false;
if(n.y / n.x > 1) //ignoring the normal''s z
return true;
else
return false;
}
i ignore the normal''s z because it describes the plane''s rotation around the vertical axis, which doesn''t matter.
checking if a plane is 'slanted'
i need to make a function that returns a bool, true would mean the plane is at an angle between the floor and a wall, and false would be a plane between the cieling and the wall. i have no idea how to do this, or what to search for. i tried this already:
The dot product between the planes normal and the floors normal is the cosine of the angle between the normals. So comparing that with the sqrt(2) will give you what you want. Assuming both normals are normalized, i.e. unit vectors.
Keys to success: Ability, ambition and opportunity.
so like this?
they are normalized
CVector Temp; Temp.x = 0; Temp.y = 1; //floor normal Temp.z = 0; if(Temp.DotProduct(&n) > 1.41f) //n is the normal return true; else return false;
they are normalized
wait, i don''t get what the sqrt(2) does, why isn''t it just comparing with 0?
The dot product of the two plane normal vectors will give you the cosine of the angle between them.
if the result == 0 (or very near to zero) then the angle is 90 perpendicular
if the result == 1 (or very near to one) then the angle is 0
obviously the result you want is 1
result = dot(normal1, normal2).
if(result == 1.0f) parrallel
also
acos(result) will give you the angle between them
if the result == 0 (or very near to zero) then the angle is 90 perpendicular
if the result == 1 (or very near to one) then the angle is 0
obviously the result you want is 1
result = dot(normal1, normal2).
if(result == 1.0f) parrallel
also
acos(result) will give you the angle between them

Oops, sorry 1/sqrt(2). From the description it seemed like you where wanting to know if the plane slants more than 45 degrees. The cosine of 45 degrees is 1/sqrt(2). You were comparing the tangent to 1 which is the tangent of 45 degrees.
Keys to success: Ability, ambition and opportunity.
actually, what i''m using this for is checking to see how far a vertical cylinder is into a plane. i can''t compare with the center of the cylinder because unless the plane is perfectly vertical, it won''t work. so i need to find out if the bottom of the cylinder is the intersecting further one, or the top. thats what i''m trying to do, so if i can test and see if a plane''s angle is between the floor and a wall, then i use the bottom of the cylinder. if its between the wall, and the cieling, i would use the top.
so the dot product returns a number 0 to 1, 1 is the planes are paralell, 0 is perpendicular? so, lets say its like .707 (45 degrees), that means the angle between them is 45?
so the dot product returns a number 0 to 1, 1 is the planes are paralell, 0 is perpendicular? so, lets say its like .707 (45 degrees), that means the angle between them is 45?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement