# Thread: Vector parallel to plane

1. ## Vector parallel to plane

Is it possible to find a vector which is parallel to a given plane ?? ( of course the normal of a plane is given as well as one point on a plane )??

2. ## Re: Vector parallel to plane

There are an infinite number of planes parallel to a given plane, each of those has an infinite number of vectors in it...
are you looking for any one in particular?

You could take a vector that is on your first plane and translate it 'up' the plane's normal...

3. ## Re: Vector parallel to plane

Yes you are right. There is infinite number of parallel vectors. But I need a vector which will be lying on this plane ( so it will be perpendicular to normal of a plane )

4. ## Re: Vector parallel to plane

Let a normal vector N=(nx,ny,nz) at a point P=(px,py,pz) on a plane.
The equation of that plane is nx*X+ny*Y+nz*Z - (nx*px+ny*py+nz+pz) = 0.
Any vector (X,Y,Z) which satisfies that equation is on the plane.
Is this an answer that you want ?

5. ## Re: Vector parallel to plane

Ok maybe I was a little bit unclear. I tell you what I really want to do.

I am writing a space strategy game. There will be some stars of course. The star is just a textured sphere and it doesnt look very impressive. I want to add some flares around it ( like in NeHe star project ). I have a texture which is 2D and whole world is 3D. So I want that texture to be ALWAYS perpendicular to camera position so it would always be seen from the front ( I dont want to see this texture or a quad it is mapped to from the angle different than 90 degs ). Such a quad ( plane ) should always pass through the centre of a star and the vector joining camera position and a star's centre should be a normal of a plane. AND FINALLY problem is how to determine 4 vertices of a quad which are on this plane to put texture there ??

Hope it is more clear now ;-)

If not please ask me once again. If you know any other idea I would be pleased to hear it.
Here is a Nehe demo to show the idea:
http://nehe.gamedev.net/data/projects/stars/stars.zip
Note that in that case everything is 2D only. So there is no problem of placing flares around star.

6. ## Re: Vector parallel to plane

this sounds like "billboarding". there's a myriad of information on this topic. search these forums or gamedev.net.

7. ## Re: Vector parallel to plane

Ah, I see. Usually those are called bill board polygons. If you're using gluLookAt then you've got all the data you'll need.

First get your camera's Forward vector by subtracting the point you're looking at from your camera's position.

Then take the cross product of the Forward vector and the vector you're using for the universal Up (I use the Z axis (0, 0, 1) for this). The result of that cross product is the Right vector of your camera.

Then take the cross product of the Forward vector and this Right vector to get the actual Up vector of the camera.

Now you've got two vectors that describe the plane of your billboard polygon. To use it, you'll have to add and subtract the up and right vectors to create the 4 vertices for the actual polygon. And, of course, you'll want to scale things so that your polygon sticks outside of your star.

Hope that helps!

8. ## Re: Vector parallel to plane

I haven't checked it out yet but I think this will solve my little prob :-)
It is called 'billboarding', it's good to know :-)
Thx ppl :-)

9. ## Re: Vector parallel to plane

I've implemented billboarding and it seems to do what I wanted but something strange is occuring. Look at this image:

Why the first texture covers the second star ( whole star ) but it doesnt cover the lines behind them all ??

PS When you look in oposite direction I mean from white star towards orange one the texture on white star DOES NOT cover the white star...

[This message has been edited by enmaniac (edited 12-22-2003).]

10. ## Re: Vector parallel to plane

I would guess that it's an alpha blending issue related to the rendering order. If you issue the command to draw the halo around the yellow star before you've drawn the white star, then the white star will not be present to be blended with the yellow halo. When you go to draw the white star's halo, the yellow star is already complete, so the blending is done correctly.

If that is what's happening, the correct way to fix that problem is to always render objects farther from the camera first. I'm not sure what the best way to accomplish that is though.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•