I am writing a function that extrudes a 2D shape along a 3D spline, as found in 3D modeling software.

I need a way of translating a set of points P so that they all lie in a new plane L (preserving distances between points).

  • P is all points where Z = 0;
  • L is defined by (0,0,0), with the normal vector N.

I am using Processing, it has common matrix and vector functionality (but no quaternions) A conceptual or pseudo-code answer is OK.

  • \$\begingroup\$ I just discovered a library for processing that includes quaternion rotation and euler angles. I've been trying to do something similar but looks like I should use this library. github.com/remixlab/proscene \$\endgroup\$
    – Andy Mac
    Commented Feb 13, 2015 at 7:10

1 Answer 1


I need a way of translating a set of points P

I suppose you mean rotating here?

Let Z = (0,0,1). If cross(N,Z) has length 0, it means that all your points already lie in the desired plane. Otherwise we can build a basis of the target plane:

  • U = normalize(cross(N,Z))
  • V = cross(N,U)

Now to transform a point P = (x,y,0) so that it lies in your target plane, simply do this:

P2 = x * U + y * V
  • \$\begingroup\$ does the line V = cross(N,V) contain a typo? V is not defined? Did you mean U? \$\endgroup\$
    – Andy Mac
    Commented Feb 17, 2015 at 3:41
  • 1
    \$\begingroup\$ oops, yes, it should be U! Fixed. \$\endgroup\$ Commented Feb 17, 2015 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .