Skip to main content
gamedev.net
🔒 Locked

Projection/Cone

Started by Whiteout 1 reply 2.3k views
Original Post
Whiteout
Whiteout
Hi, I am trying to project a point x in 3D Space onto a point x' on the surface of a cone. x' should be the point on the cone's surface closest to the original point x such that the normalized vector x-x' is the cone's surface normal in the point x'. The Cone is parameterize in two distinct ways... (1) - the cone's apex a e R³ - the cone's normal n e R³ - the cone's opening semi-angle alpha (2) - a point p e R³ on the cone's axis but not the apex - a normal n e R³ pointing from p towards the axis - the ortohgonal distance s from from p to the cone's surface - the opening semi-angle alpha I have thought quite a lot about this problem but have not come up with a satisfying result. Does anybody know a solution and is willing to help out? Thanks a lot...
Zipster
Zipster
The closest point is going to be on the plane defined by x, the cone's apex, and a point on the cone's axis other than the apex. When you intersect this plane with the cone, you should get two lines. The problem then simplifies to finding the closest point on each line, and choosing the smaller distance of the two solutions.

You can either do the problem in the original space, or you can transform everything to a space where the cone's apex is the origin, and its axis is aligned to X/Y/Z. Then once you find a solution you reverse the transformation. If you're confident with your 3D linear algebra then you shouldn't need to do this, but it can simplify many aspects of the problem.
Whiteout
Whiteout
Quote:
Original post by Zipster
The closest point is going to be on the plane defined by x, the cone's apex, and a point on the cone's axis other than the apex. When you intersect this plane with the cone, you should get two lines. The problem then simplifies to finding the closest point on each line, and choosing the smaller distance of the two solutions.

You can either do the problem in the original space, or you can transform everything to a space where the cone's apex is the origin, and its axis is aligned to X/Y/Z. Then once you find a solution you reverse the transformation. If you're confident with your 3D linear algebra then you shouldn't need to do this, but it can simplify many aspects of the problem.


Thank's a lot for your thoughts on this one Zipster! I came up with a different solution now but your idea sure helped me to get to this point now!

My solution (if anyone is interested)...


Vector3f Cone::getNormalOfProjection( Vector3f p_ ){        //choose new coord system with the the base vectors...        //a. cone normal        //b. a perpendicular vector u pointing towards p_        //c. a third vector, perpendicular to normal and u  	Vector3f u = ( p_ - m_apex ); 	u = u - ( m_normal * ( u * m_normal ) );	u.normalize();	Vector3f v = m_normal.crossProduct( u );	v.normalize();        //transformation matrix of the new coord system	Matrix3f m = makeMatrix3f( m_normal[0], m_normal[1], m_normal[2],		                          u[0],        u[1],        u[2],			 		  v[0],        v[1],        v[2] );		//p_ transformed in alternate coord system        //(translated, such that the apex is centered in the origin)	Vector3f p = m * ( p_ - m_apex );	//definition of point x which is the point of intersection	//of the line defined by p_ and the searched normal        //and the axis of the cone	        Vector3f x;	if( p[0] < 0 )		x = makeVector3f( p[0] - tan( m_alpha ) * p[1], 0.0f, 0.0f );	else		x = makeVector3f( p[0] + tan( m_alpha ) * p[1], 0.0f, 0.0f );	//transform x back into world coord system        x = ( m.transpose() * x ) + m_apex;	//the normal of the projected point is p_ - x	        Vector3f n = p_ - x;	n.normalize();        return n;}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.