# Compute the normal of a 2D spline using animation nodes

In this question I asked how to deform an object with an spline using animation nodes. The technique explained there the deformation considers all 3 dimensions tilting the output object, but what if I want to deform this object locking the tilt as if it was done with a 2D spline but still deform in a 3d space?, exactly as it is done here.

EDIT

Using @Omar Ahmad answer I managed to get the results I needed. but I'm still a little bit confused. The following image shows the resulting graph:

I'm not quite sure if the new computed normal is correctly linked as in order to get the desired results I was forced to increment its Z value up to 1000.

• You have two normalize nodes, the first one should be connected to the newly computed normals and the second one should be connected to the constant vector (0, 0, 1). Moreover, make sure the spline is indeed 2D by making its points have a z location of 0. Jun 6, 2019 at 9:02

The normal to a point on a spline is equal to the tangent at this point rotated by 90 degrees around the z axis. Let the tangent be $$\vec{t} = (x, y)$$, then the normal is equal to $$R\vec{t}$$, where $$R$$ is a 2D rotation matrix with an angle of $$\frac{\pi}{2}$$. So the normal is equal to:
$$\begin{bmatrix} \cos \frac{\pi}{2} & -\sin \frac{\pi}{2} \\ \sin \frac{\pi}{2} & \cos \frac{\pi}{2} \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} -y \\ x \end{bmatrix}$$
To deform an object as described in the answer you linked, you will need a third vector, the one we computed using the cross product. In this case, it will always be the vector $$(0, 0, 1)$$.