Sign in to follow this  
akaitora

Plane notation

Recommended Posts

Hi guys. I am currently reading "Game Engine Architecture" by Jason Gregory. While reading through the 3d math chapter, Gregory talks about how most game engines represent planes. Generally they are represented by a normal vector and distance from the origin like so [(vx vy vz) d] This is a little confusing to me however. Imagine you have a 2 planes, p1 and p2. Imagine that the d value for both planes is 5. Both planes are also oriented in the same exact direction. How would I represent a plane that is behind the origin and one that is in front? It is entirely possible to have to planes with the same orientation and magnitude but with different positions in 3d space. How would I account for this with the proposed structure? Thanks in advance!

Share this post


Link to post
Share on other sites
The "distance" d has sign. It is measured along the direction indicated by (vx,vy,vz). So the two planes in your example would have d=5 and d=-5.

Alternatively, you could flip the sign of the vector, in which case your two planes would be [(vx,vy,vz),5] and [(-vx,-vy,-vz),5].

Share this post


Link to post
Share on other sites
Thanks for the response. That still doesn't make sense to me.
Imagine I have a unit cirle around the origin. No matter where I place my plane's origin, it's distance will always be 1 away from the origin. I don't see how changing d's sign makes a difference. What would be the difference between a plane 1 unit in front of the origin and a plane 1 unit to the right of the origin?

Share this post


Link to post
Share on other sites
Then the plane is not placed on the unit circle as you asked for, but at the origin. The normal will be pointing in the positive look direction, and the distance is zero since it passes through the origin.

A plane does not have a position, only the direction it's facing and the distance between the origin and the plane along the normal. The plane extends infinitely in all directions on the plane, so it doesn't make sense to talk about positioning a plane in the sense you're asking about.

Share this post


Link to post
Share on other sites

That a plane has no position means there is no single position where you can say "here's the plane". It spans all the way to +/- infinity, so there are an infinite number of positions that are 'on' the plane, but no single one formally defines it. I'm sure someone else can explain this better and more mathematically correct, but I hope this is some start at least [smile]

Now practically, without a distance from the origin a plane would be rather limited since you could only set up a plane right there, at the origin. Requiring each plane to contain the origin is needless and a bit useless, so you can specify a distance to move it away from the origin along its normal. Perhaps this will clear things up:



Both green areas represent part of a plane with normal (0,1,0), if you follow me in arbitrarily assigning (0,1,0) as 'up' in our coordinate system. The plane to the right has a certain value for d along which it is moved away from the origin along its normal. Without allowing for such a distance d, this righthand plane could not have been defined.

What is perhaps confusing you is that it's somewhat wrong to think of a plane as a finite piece of geometry like in the picture. It helps to visualize the orientation of the plane, but the key here is that it actually extends to infinity to the sides and 'front & back' (along the x and z axis in this particular coordinate system). This can be tricky to wrap your head around, but along these lines lies the reason you can't say that for example the left-hand plane lies at (0,0,0); the entire 2D surface (x, 0, z) where x and z is an arbitrary number is that plane.

Share this post


Link to post
Share on other sites
The plane is defined to be all points of the space that have a zero distance to, well, the plane. To compute the distance of any arbitrary point p in space, you pick a point on the plane o so that you can compute the difference vector:
p - o
But the length of this vector isn't equal to the distance of the point p from the plane because the difference vector may make some angle (of not 90°) with the plane, but the distance is measured straight down onto the plane. So you have to project the difference vector onto the unit normal n of the plane:
( p - o ) . n
As said, points on the plane have a distance of 0, hence:
( p - o ) . n == 0
Now resolve the paranthesis
p . n - o . n == 0
and remember that both o and n are constant w.r.t. the plane, so we can compute it once as
d := o . n
If you think of the previous application of the dot-product then you'll see an analogy: The parameter d is the projected length of the point vector of the plane. In other words, d denotes the shortest distance of the plane to the global origin.

Share this post


Link to post
Share on other sites
Quote:
So if a plane has no position, what is the purpose of attributing a distance from the origin to it?
I probably won't be adding anything new to the discussion here, but here's one more way to think about it. Imagine a plane that includes (i.e. passes through) the origin. The plane has a normal, pointing in some direction. If you 'slide' the plane along the normal, it moves away from the origin. You can slide the plane as far as you want in either direction along the normal; when the origin is on one side of the plane the (signed) distance to the origin is positive, and when it's on the other side the distance is negative. When the plane is right 'on' the origin the distance is zero.

By sliding the plane along the normal you can represent many of the infinite number of possible planes (an infinite number of them, in fact :), but you can't represent all of them. However, if you are allowed first to orient the plane however you want (that is, change the direction in which the normal points), and then slide the plane along the normal, you can represent every possible plane. The normal represents the 'orienting' step, and the distance represents the 'sliding' step.
Quote:
So if a plane has no position, what is the purpose of attributing a distance from the origin to it?
The 'distance' we speak of is not a 'distance between points'. Rather, it is the signed, perpendicular distance from the origin to the plane. You can also think of it as being the shortest distance between the origin and the plane (i.e. the distance with the smallest magnitude) .

Share this post


Link to post
Share on other sites
Quote:
Original post by akaitora
But what if I want a plane to be positioned to the right of the origin but facing down the positive look direction?
That would be impossible. Remember that a plane is an infite 2D area, not a bespoke piece of model data. With that in mind, you can't "position" it like that at all. The plane is fully defined by it's looking direction and it's distance down that direction from the world origin.

In your example, if the plane were "looking" in the "forward" direction, it's normal would be [0,0,1] (or [0,0,-1] if you're used to that method) and it's distance would be anything you like, depending on how far in front of or behind the origin you want it to be - you don't get the option to move sideways as well, nor do you need it - it fills ALL of "sideways" already.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this