Projects a vector onto another vector. The vector to project. The projection normal vector. The projected vector.
(Vector3 vector, Vector3 onNormal)
| 1353 | /// <param name="onNormal">The projection normal vector.</param> |
| 1354 | /// <returns>The projected vector.</returns> |
| 1355 | public static Vector3 Project(Vector3 vector, Vector3 onNormal) |
| 1356 | { |
| 1357 | Real sqrMag = Dot(onNormal, onNormal); |
| 1358 | if (sqrMag < Mathr.Epsilon) |
| 1359 | return Zero; |
| 1360 | return onNormal * Dot(vector, onNormal) / sqrMag; |
| 1361 | } |
| 1362 | |
| 1363 | /// <summary> |
| 1364 | /// Projects a vector onto a plane defined by a normal orthogonal to the plane. |