using System; using System.Runtime.InteropServices; namespace SFML { namespace Audio { //////////////////////////////////////////////////////////// /// /// Vector3 is an utility class for manipulating 3 dimensional /// vectors with float components /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct Vector3 { //////////////////////////////////////////////////////////// /// /// Construct the vector from its coordinates /// /// X coordinate /// Y coordinate /// Z coordinate //////////////////////////////////////////////////////////// public Vector3(float x, float y, float z) { X = x; Y = y; Z = z; } //////////////////////////////////////////////////////////// /// /// Operator - overload ; returns the opposite of a vector /// /// Vector to negate /// -v //////////////////////////////////////////////////////////// public static Vector3 operator -(Vector3 v) { return new Vector3(-v.X, -v.Y, -v.Z); } //////////////////////////////////////////////////////////// /// /// Operator - overload ; subtracts two vectors /// /// First vector /// Second vector /// v1 - v2 //////////////////////////////////////////////////////////// public static Vector3 operator -(Vector3 v1, Vector3 v2) { return new Vector3(v1.X - v2.X, v1.Y - v2.X, v1.Z - v2.Z); } //////////////////////////////////////////////////////////// /// /// Operator + overload ; add two vectors /// /// First vector /// Second vector /// v1 + v2 //////////////////////////////////////////////////////////// public static Vector3 operator +(Vector3 v1, Vector3 v2) { return new Vector3(v1.X + v2.X, v1.Y + v2.X, v1.Z + v2.Z); } //////////////////////////////////////////////////////////// /// /// Operator * overload ; multiply a vector by a scalar value /// /// Vector /// Scalar value /// v * x //////////////////////////////////////////////////////////// public static Vector3 operator *(Vector3 v, float x) { return new Vector3(v.X * x, v.Y * x, v.Z * x); } //////////////////////////////////////////////////////////// /// /// Operator * overload ; multiply a scalar value by a vector /// /// Scalar value /// Vector /// x * v //////////////////////////////////////////////////////////// public static Vector3 operator *(float x, Vector3 v) { return new Vector3(v.X * x, v.Y * x, v.Z * x); } //////////////////////////////////////////////////////////// /// /// Operator / overload ; divide a vector by a scalar value /// /// Vector /// Scalar value /// v / x //////////////////////////////////////////////////////////// public static Vector3 operator /(Vector3 v, float x) { return new Vector3(v.X / x, v.Y / x, v.Z / x); } //////////////////////////////////////////////////////////// /// /// Provide a string describing the object /// /// String description of the object //////////////////////////////////////////////////////////// public override string ToString() { return "[Vector3]" + " X = " + X + " Y = " + Y + " Z = " + Z; } /// X (horizontal) component of the vector public float X; /// Y (vertical) component of the vector public float Y; /// Z (depth) component of the vector public float Z; } } }