• Advertisement
Sign in to follow this  

Getting the extends of a plane intersection the view frustrum

This topic is 1004 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

 

I'm trying to get four corner coordinates of a plane, where it is bound in my view frustrum.

 

As illustrated here:

qQWHS3t.jpg

 

I want to get the XYZ coordinates of the intersection of the view frustrum with my plane in real space.  The plane is infinite, and always with a normal pointing straight upwards.

 

Is there an easy way to do this?

Edited by JohnnyLightwave

Share this post


Link to post
Share on other sites
Advertisement

well it depends on what you call an "easy way" but I guess it's quite simple.

 

since the normal is always upward things get easier, also you haven't mentioned if you have the coordinates of a point on the plane or not. you can't define a plane only by its normal. So lets say you have the point (x0,y0,z0) on the plane and frustum's near plane's vertical lines are L1 and L2 .

 

What you are trying to achieve is the points on the L1 and L2 with the y coordinates  of y0. So given to ending points of L1 as (x2,y2,z2),(x1,y1,z1) and the two end of and L2 as (x3,y3,z3) and (x4y4,z4) (all of these in view space) you have the two intersection points of:

 

((x4 - x3)* (y4 - y0) / (y4 - y3) + x3 , y0 , (z4 - z3)* (y4 - y0) / (y4 - y3) + z3) and ((x2- x1)* (y2 - y0) / (y2 - y1) + x, y0 , (z2 - z1)* (y2- y0) / (y2 - y1) + z1)

 

its a simple interpolation don't get scared (also don't try to run biggrin.png ).

 

you can do the same with the far plane's vertical line (actually they don't have to be vertical) now these points are still in view space to get them to "real space" you should simply multiply them by the inverse of the view matrix

Edited by IYP

Share this post


Link to post
Share on other sites

Hi IYP,

 

Thanks for the terrifying equation help!

 

Let me ask this...

I define my planes like this:

//
// Plane
//
class Plane
{
	Vector		mPos;
	Vector		mNormal;
	float		mD;

	void Create(Vector thePoint, Vector theNormal)
	{
		mPos=thePoint;
		mNormal=theNormal;
		mD=-theNormal.Dot(thePoint);
	}
};

//
// Frustrum
//
enum
{
    FRUSTRUM_RIGHT=0,
    FRUSTRUM_LEFT,
    FRUSTRUM_TOP,
    FRUSTRUM_BOTTOM,
    FRUSTRUM_NEAR,
    FRUSTRUM_FAR
};
class Frustrum
{
	Plane					mPlane[6];
};

So essentially my frustrum is just a bunch of planes cutting into eachother.  While I'm good with 2D, I have trouble conceptually adding that third dimension into equations (I do 2D geometry native, but am just an idiot savant in 3d), so I'm a little unsure how I would extract L1 and L2 from my set of six planes (except via a brute force method that would do the trick but probably is optimized away by pure math).

 

Do you think you could give me a suggestion on how to extract from these classes into the variables to plug into your dread equation of darkness?

 

Thanks!

Edited by JohnnyLightwave

Share this post


Link to post
Share on other sites

ok now I see the things you have are quite not that easy to calculate, I would simply define a frustum by 8 points but you do it with 6 plane, but you still can calculate them.

 

What you do is to find the intersection points of 4 set of 3 planes at near and far plane. So you have a mPlane[6] in the frustum class, lets say mPlane[0] and mPlane[5] are the near and far planes and others are the side plane if these plane are properly evaluated you will get a single point as a result of the intersection of the there mPlane[0] , mPlane and mPlane[i+1] planes (the intersection point of 2 side planes and a near plane), these intersections should give you 4 point on the near plane the same kind of intersection will result in 4 other point on the far plane. now you have 8 points defining the frustum.

 

[attachment=28297:Untitled.png]

 

now you have calculate the P1, P2, P3, P4, P5, P6, P7 and P8 by intersecting proper planes (as said above) then you will have the P1(x1,y1,z1 )and P4(x2,y2,z2)  and P2 (x3,y3,z3) and P3 (x4y4,z4) and now you can find the intersection of your plane with that formula (the P1 and P4 are on the L1 line which is vertical and the P2 and P3 are on the L2 line also vertical) doing the same with far plane's point you can achieve the other pair of point and you will have 4 point representing the intersection 

Edited by IYP

Share this post


Link to post
Share on other sites

or lemme simplify stuff to be more convenient for your method. do a simple intersection between the a side plane, near plane and the intersecting plane (do this twice once for each vertical side plane) then do the same but this time with the far plane instead of near plane. considering that you have the equation of the planes this should be the most straight forward method.

 

for plane intersection make a matrix of the planes' normals (3 planes makes a 3x3 matrix) and then make a point out of D values of the equation, then inverse the matrix and multiply the point by it. 

Edited by IYP

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement