12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MathNet.Numerics.LinearAlgebra.Single;
- namespace bbiwarg.DataSource
- {
- public static class VectorExtender
- {
- public static Vector Cross(this Vector v, Vector other)
- {
- if ((v.Count != 3 || other.Count != 3))
- {
- string message = "Vectors must have a length of 3.";
- throw new Exception(message);
- }
- Vector result = new DenseVector(3);
- result[0] = v[1] * other[2] - v[2] * other[1];
- result[1] = -v[0] * other[2] + v[2] * other[0];
- result[2] = v[0] * other[1] - v[1] * other[0];
- return result;
- }
-
- public static float x(this Vector v)
- {
- return v[0];
- }
- public static float y(this Vector v)
- {
- return v[1];
- }
- public static float z(this Vector v)
- {
- return v[2];
- }
- }
- }
|