/// <summary> /// Returns a copy of the Vector3k scaled to unit length. /// </summary> public Vector3k Normalized() { Vector3k v = this; v.Normalize(); return(v); }
public static Vector3k CalculateSurfaceNormal(Vertex [] verts) { Vector3k normal = new Vector3k(Accum.Zero, Accum.Zero, Accum.Zero); Vertex cur, next; int vCount = verts.Length; for (int i = 0; i < vCount; i++) { cur = verts [i]; next = verts [(i + 1) % vCount]; normal.X += (cur.Y - next.Y) * (cur.Z + next.Z); normal.Y += (cur.Z - next.Z) * (cur.X + next.X); normal.Z += (cur.X - next.X) * (cur.Y + next.Y); } normal.Normalize(); return(normal); }
/// <summary> /// Converts a Vector3k to OpenTK's Vector3d type /// </summary> /// <param name="vec"></param> /// <returns></returns> public static Vector3d ToVec3d(this Vector3k vec) { return(new Vector3d((double)vec.X, (double)vec.Y, (double)vec.Z)); }
public Vector3k(Vector3k vec) : this(vec.x, vec.y, vec.z) { }
/// <summary> /// Converts a Vector3k to OpenTK's Vector3 type /// </summary> /// <param name="vec"></param> /// <returns></returns> public static Vector3 ToVec3(this Vector3k vec) { return(new Vector3((float)vec.X, (float)vec.Y, (float)vec.Z)); }