Sign in to follow this  
tKircher

Using a 3D plane's 2D coordinates

Recommended Posts

tKircher    122
I have a 3D plane that i need to be able to use very much like a traditional 2D "coordinate system." That is, i have points on the plane, and i wish to find the distance between them in X and Y across the plane, rather than the 3D coordinates of the plane itself or the world around it. I know it has something to do with linear algebra and orthogonal projection, but i can't find any good resources dealing with this sort of problem, so i'm at a loss for an algorithm or even a starting place. My plane is defined by an origin and normal (or is defined by just a single vector, if you wish to be strictly orthodox about it), and the 'origin' is even where i would ideally like to use as (0, 0), help's appreciated.

Share this post


Link to post
Share on other sites
grhodes_at_work    1385
If the points are definitely on the plane (e.g., not above or below), then the distance between them across the plane (e.g., the 2D distance you asked about) is exactly the same as the 3D distance. Without doing projections, you do have to use the 3D coordinates of the points to compute the distance, but in the end you'd end up with the same # that you would calculate if you projected into a 2D subspace that exists on the plane, then compute the distance in the subspace.

I suspect you want more than you asked, but I think that addresses your question...

If you do want to know about finding the 2D vector difference (e.g., not merely a distance) between two points on the plane, then the first question to ask yourself is: "what is x and what is y?", e.g., what subspace are you interested in measuring things in? There are infinitely many possibly combinations of x and y directions within the plane! But there are some pretty simple approaches should you decide you don't care, as long as you have something in-plane.

Share this post


Link to post
Share on other sites
tKircher    122
You're right, i didn't really explain the entirety of what i was after.

I'm trying to create a multitextured effect that applies its' effect across multiple tris (for which i've created planes), so the idea is to find appropriate texture coordinates for the effect's texture for each vertex on the plane. To do so, i can't simply find regular distance (otherwise only half the texture will ever be applied to the geometry, which wouldn't look right).

Anyway, long story short, i need to use the planes i've created as 2D 'canvases' so i can properly put the effect anywhere in the game world. The easiest way i can think to do this is to use the planes as arbitrary 2D "graphs" much like one would use an orthogonal projection in DX or GL, or in a simple 2D game.

Which brings me back to trying to find out how to use an arbitrary 3D plane with 2D coordinates.

Share this post


Link to post
Share on other sites
D_Tr    362
If I understood correctly, what you need is a point "o" and two 3D axes "x" and "y" lying on your plane. Then, given the coordinates (a, b) you can do:

o + a * x + b * y, and you get the point on your plane.

Share this post


Link to post
Share on other sites
oliii    2196
for that you'll need some sort of frame to define the plane's 'orientation'.

If you have a normal, then you can work out two perpendicular unit vectors that are on the plane, and an origin (a point in the plane).

Then the texture mapping of any point (P) on that plane, with respect to the frame (origin O, vectors I, J) would be.

u = (P - O).dotProduct(I).
v = (P - O).dotProduct(J).


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