views:

136

answers:

2

Hello,

I can easily draw the projection of a 3D set of points onto the plane with normal vector (1,1,1), by using the matrix

    (-sqrt(3)/2   sqrt(3)/2   0)
    (-1/2         -1/2        1).

I want to do the same thing, but for a projection onto an arbitrary plane with normal vector (a,b,c) instead of (1,1,1). How to find the matrix?

Thanks in advance!

EDIT: rephrasing of the question:

When viewing from (1,1,1), the three unit vectors are projected to (-sqrt(3)/2, -1/3), (sqrt(3)/2, -1/2), (0,1). (Up to a scaling factor which doesn't matter.)

I want to find the projection of the three unit vectors when viewed from (a,b,c) instead of (1,1,1).

A: 

Back when I wrote such a code, I simply used wikipedia's nice article on this topic.

There are additional ressources available here and here. There is also a related question on SO.

mafutrct
Thanks; I have read this article but it assumes that "the normal of the viewing plane (the camera direction) is parallel to one of the 3D axes", which is not my case.
leipäjuusto
I recall having a similar issue, but it was rather easy to work around. How about first projecting (as described) then rotating the viewing plane so it becomes the XY plane? The rotation is quite simple code. Does that work for you?
mafutrct
What projection do you mean?I would like to encode both the projection and the rotation in my 2*3 matrix. (2*3 is possible because I assume all the planes to lie on the origin, so there's no dependence on a base point or something.)
leipäjuusto
I mean the projection on the viewing plane.
mafutrct
OK, that sounds fine. I have done the projection part and I am very glad now it works; I achieved the main part of what I wanted. But now, the rotation would be a "bonus", to rescale my result nicely. Is it possible to encode the rotation in a 2*3 matrix to have the (x,y) coordinates from the (x,y,z) coordinates, starting from the normal vector (a,b,c)?
leipäjuusto
Sorry, I don't know :) Been a long time since I did this stuff
mafutrct
A: 

I'm afraid you're can't stuck with 3x2 matrix in arbitrary plane case. Here is a great paper for exactly what you're looking for.

nailxx