Search code examples
matlab3dcoordinatesprojection

How can I project a group of points in 3D space onto a 2D plane in Matlab?


I'm making an animation in Matlab: I have 15 dots moving around in a 3D space. Their XYZ co-ordinates and movement are taken from motion-capture data. I need to show how the dots are moving from the perspective of an observer "in front" of the motion. What I'm trying right now is to create a 2D plane and to move it towards the dots so that they end up "projected" onto it. However, it's not a standard X-Y or Y-Z plane, so I'm having trouble figuring out how to make this work.

How can I make this plane do what I want - or is there another way I should be trying?


Solution

  • What you're aiming for is basically implementing an ideal pinhole camera, where the pinhole becomes a point in space. Each of your 3D points plus the "pinhole" defines a line in 3D space, which intersects with your projection plane at some point. It looks somewhat like this: pinhole camera

    x_1 and y_1 should have the same length, i.e. 1, so "x" in 3D space is defined as x = o_1 + a * x_1 + b * y_1. In your 2D projection, a and b become your coordinates for plotting.