public Vector4f(Vector3f v, float w) { X = v.X; Y = v.Y; Z = v.Z; W = w; }
public static Vector3f Cross(Vector3f v1, Vector3f v2) { throw new NotImplementedException(); /*return new Vector3f( v1.Y * v2.Z - v2.Y * v1.Z, v1.Z * v2.X - v2.X * v1.Z, v1.X * v2.Z - v2.Y * v1.X );*/ }
public static Vector3f ComponentMultiply(Vector3f v1, Vector3f v2) { return new Vector3f(v1.X * v2.X, v1.Y * v2.Y, v1.Z * v2.Z); }
public static Vector3f ComponentDivide(Vector3f v1, Vector3f v2) { return new Vector3f(v1.X / v2.X, v1.Y / v2.Y, v1.Z / v2.Z); }
public Vector3f TransformRelative(Vector3f v) { return (this * new Vector4f(v, 0)).XYZ; }
public static Quaternion CreateFromAxisAngle(Vector3f axis, float angle) { return CreateFromUnitAxisAngle(axis.Normalized, angle); }
public static float Dot(Vector3f vL, Vector3f vR) { return Vector3f.Dot(vL, vR); }
public static float Dot(Vector3f v1, Vector3f v2) { return v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z; }
public static Matrix4f CreateRotation(float angle, Vector3f axis) { Vector3f u = axis.Normalized; float c = (float)Math.Cos(angle); float s = (float)Math.Sin(angle); Matrix4f result = Matrix4f.Identity; result[0, 0] = u.X * u.X + (1 - u.X * u.X) * c; result[0, 1] = u.X * u.Y * (1 - c) - u.Z * s; result[0, 2] = u.X * u.Z * (1 - c) + u.Y * s; result[1, 0] = u.X * u.Y * (1 - c) + u.Z * s; result[1, 1] = u.Y * u.Y + (1 - u.Y * u.Y) * c; result[1, 2] = u.Y * u.Z * (1 - c) - u.X * s; result[2, 0] = u.X * u.Z * (1 - c) - u.Y * s; result[2, 1] = u.Y * u.Z * (1 - c) + u.X * s; result[2, 2] = u.Z * u.Z + (1 - u.Z * u.Z) * c; return result; }
public Quaternion(float w) { this.w = w; this.v = Vector3f.Zero; }
public Quaternion(float w, float x, float y, float z) { this.w = w; this.v = new Vector3f(x, y, z); }
public Quaternion(float w, Vector3f v) { this.w = w; this.v = v; }
//Requires a normalized quaternion public Vector3f RotateVector(Vector3f vec) { Debug.Assert(IsNormalized); throw new NotImplementedException(); }
public static Quaternion CreateFromUnitAxisAngle(Vector3f axisUnitVector, float angle) { //Debug.Assert(axisUnitVector.IsUnit); float angle2 = 0.5f * angle; return new Quaternion((float)Math.Cos(angle2), axisUnitVector * (float)Math.Sin(angle2)); }
public static float Distance(Vector3f v1, Vector3f v2) { return (v1 - v2).Length; }
public static float DistanceSquared(Vector3f v1, Vector3f v2) { return (v1 - v2).LengthSquared; }
public static Matrix4f CreateTranslation(Vector3f v) { return new Matrix4f(Vector4f.UnitX, Vector4f.UnitY, Vector4f.UnitZ, new Vector4f(v, 0)); }
/*public float Dot(Vector4f vL, Vector4f vR) { return Vector4f.Dot(vL, vR); }*/ public static Vector3f Cross(Vector3f vL, Vector3f vR) { return Vector3f.Cross(vL, vR); }
/// <summary> /// Requires Col(3)==UnitW /// </summary> public Matrix4f AppendTranslation(Vector3f v) { Matrix4f result = this; result.row3 += new Vector4f(v, 0); return result; }
public RayF(Vector3f start, Vector3f direction) : this() { Direction = direction.Normalized; Start = start; }
public Vector3f TransformAbsolute(Vector3f v) { return (this * new Vector4f(v, 1)).XYZ; }