コード例 #1
0
        /// <summary>
        /// Converts the given object to the type of this converter, using the specified context and culture information.
        /// </summary>
        /// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
        /// <param name="culture">The <see cref="System.Globalization.CultureInfo"/> to use as the current culture. </param>
        /// <param name="value">The <see cref="Object"/> to convert.</param>
        /// <returns>An <see cref="Object"/> that represents the converted value.</returns>
        /// <exception cref="ParseException">Failed parsing from string.</exception>
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (value.GetType() == typeof(string))
            {
                return(Vector4F.Parse((string)value));
            }

            return(base.ConvertFrom(context, culture, value));
        }
コード例 #2
0
ファイル: Vector4F.cs プロジェクト: ddanninger/PLMPack
 /// <summary>
 /// Tests whether two vectors are approximately equal given a tolerance value.
 /// </summary>
 /// <param name="left">A <see cref="Vector4F"/> instance.</param>
 /// <param name="right">A <see cref="Vector4F"/> instance.</param>
 /// <param name="tolerance">The tolerance value used to test approximate equality.</param>
 /// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns>
 public static bool ApproxEqual(Vector4F left, Vector4F right, float tolerance)
 {
     return
         (
         (System.Math.Abs(left.X - right.X) <= tolerance) &&
         (System.Math.Abs(left.Y - right.Y) <= tolerance) &&
         (System.Math.Abs(left.Z - right.Z) <= tolerance) &&
         (System.Math.Abs(left.W - right.W) <= tolerance)
         );
 }
コード例 #3
0
ファイル: Vector4F.cs プロジェクト: ddanninger/PLMPack
        /// <summary>
        /// Converts the given value object to the specified type, using the specified context and culture information.
        /// </summary>
        /// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
        /// <param name="culture">A <see cref="System.Globalization.CultureInfo"/> object. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed.</param>
        /// <param name="value">The <see cref="Object"/> to convert.</param>
        /// <param name="destinationType">The Type to convert the <paramref name="value"/> parameter to.</param>
        /// <returns>An <see cref="Object"/> that represents the converted value.</returns>
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if ((destinationType == typeof(string)) && (value is Vector4F))
            {
                Vector4F v = (Vector4F)value;
                return(v.ToString());
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
コード例 #4
0
ファイル: Vector4F.cs プロジェクト: ddanninger/PLMPack
        /// <summary>
        /// Converts the specified string to its <see cref="Vector4F"/> equivalent.
        /// A return value indicates whether the conversion succeeded or failed.
        /// </summary>
        /// <param name="value">A string representation of a <see cref="Vector4F"/>.</param>
        /// <param name="result">
        /// When this method returns, if the conversion succeeded,
        /// contains a <see cref="Vector4F"/> representing the vector specified by <paramref name="value"/>.
        /// </param>
        /// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
        public static bool TryParse(string value, out Vector4F result)
        {
            Regex r = new Regex(@"\((?<x>.*),(?<y>.*),(?<z>.*),(?<w>.*)\)", RegexOptions.Singleline);
            Match m = r.Match(value);

            if (m.Success)
            {
                result = new Vector4F(
                    float.Parse(m.Result("${x}")),
                    float.Parse(m.Result("${y}")),
                    float.Parse(m.Result("${z}")),
                    float.Parse(m.Result("${w}"))
                    );

                return(true);
            }

            result = Vector4F.Zero;
            return(false);
        }
コード例 #5
0
ファイル: Camera.cs プロジェクト: azykise/olawork
        public virtual Vector3F getScreenWorldLocation(int x,int y,View view)
        {
            this.doUpdate(view.RenderSystem);

            int w = view.RenderWindow.getWidth();
            int h = view.RenderWindow.getHeight();

            Vector4F vec = new Vector4F();
            vec.X = m_view_param.NearDist * (((2.0f * x) / w) - 1.0f);
            vec.Y = m_view_param.NearDist * (((2.0f * (h - y)) / h) - 1.0f);
            vec.Z = 0.0f;
            vec.W = m_view_param.NearDist;

            Matrix4F vpInverse = (m_projmat * m_viewmat).Inverse();

            vec = vpInverse * vec;
            vec /= vec.W;

            return new Vector3F(vec.X, vec.Y, vec.Z);
        }
コード例 #6
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Initializes a new instance of the <see cref="Vector4F"/> class using coordinates from a given <see cref="Vector4F"/> instance.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> to get the coordinates from.</param>
		public Vector4F(Vector4F vector)
		{
			_x = vector.X;
			_y = vector.Y;
			_z = vector.Z;
			_w = vector.W;
		}
コード例 #7
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Calculates the dot product of two vectors.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance.</param>
		/// <returns>The dot product value.</returns>
		public static float DotProduct(Vector4F left, Vector4F right)
		{
			return (left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z) + (left.W * right.W);
		}
コード例 #8
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Divides a vector by a scalar.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A scalar</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		/// <remarks>
		/// result[i] = vector[i] / scalar
		/// </remarks>
		public static void Divide(Vector4F vector, float scalar, ref Vector4F result)
		{
			result.X = vector.X / scalar;
			result.Y = vector.Y / scalar;
			result.Z = vector.Z / scalar;
			result.W = vector.W / scalar;
		}
コード例 #9
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Divides a vector by another vector.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance.</param>
		/// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
		/// <remarks>
		///	result[i] = left[i] / right[i].
		/// </remarks>
		public static Vector4F Divide(Vector4F left, Vector4F right)
		{
			return new Vector4F(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W);
		}
コード例 #10
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Subtracts a vector from a scalar.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A single-precision floating-point number.</param>
		/// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
		/// <remarks>
		/// result[i] = scalar - vector[i]
		/// </remarks>
		public static Vector4F Subtract(float scalar, Vector4F vector)
		{
			return new Vector4F(scalar - vector.X, scalar - vector.Y, scalar - vector.Z, scalar - vector.W);
		}
コード例 #11
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Adds two vectors and put the result in the third vector.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		public static void Add(Vector4F left, Vector4F right, ref Vector4F result)
		{
			result.X = left.X + right.X;
			result.Y = left.Y + right.Y;
			result.Z = left.Z + right.Z;
			result.W = left.W + right.W;
		}
コード例 #12
0
ファイル: Vector4F.cs プロジェクト: ddanninger/PLMPack
 /// <summary>
 /// Divides a vector by a scalar.
 /// </summary>
 /// <param name="vector">A <see cref="Vector4F"/> instance.</param>
 /// <param name="scalar">A scalar</param>
 /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = vector[i] / scalar;
 /// </remarks>
 public static Vector4F operator /(Vector4F vector, float scalar)
 {
     return(Vector4F.Divide(vector, scalar));
 }
コード例 #13
0
ファイル: Vector4F.cs プロジェクト: ddanninger/PLMPack
 /// <summary>
 /// Multiplies a vector by a scalar.
 /// </summary>
 /// <param name="vector">A <see cref="Vector4F"/> instance.</param>
 /// <param name="scalar">A single-precision floating-point number.</param>
 /// <returns>A new <see cref="Vector4F"/> containing the result.</returns>
 public static Vector4F operator *(float scalar, Vector4F vector)
 {
     return(Vector4F.Multiply(vector, scalar));
 }
コード例 #14
0
ファイル: Vector4F.cs プロジェクト: ddanninger/PLMPack
 /// <summary>
 /// Subtracts a vector from a scalar.
 /// </summary>
 /// <param name="vector">A <see cref="Vector4F"/> instance.</param>
 /// <param name="scalar">A single-precision floating-point number.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = scalar - vector[i]
 /// </remarks>
 public static Vector4F operator -(float scalar, Vector4F vector)
 {
     return(Vector4F.Subtract(scalar, vector));
 }
コード例 #15
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Divides a scalar by a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = s / v[i]
 /// </remarks>
 public static Vector4F operator /(float s, Vector4F v)
 {
     return(Vector4F.Divide(s, v));
 }
コード例 #16
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Adds two vectors.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance.</param>
		/// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns>
		public static Vector4F Add(Vector4F left, Vector4F right)
		{
			return new Vector4F(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
		}
コード例 #17
0
ファイル: Vector4F.cs プロジェクト: ddanninger/PLMPack
 /// <summary>
 /// Divides a scalar by a vector.
 /// </summary>
 /// <param name="vector">A <see cref="Vector4F"/> instance.</param>
 /// <param name="scalar">A scalar</param>
 /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = scalar / vector[i]
 /// </remarks>
 public static Vector4F operator /(float scalar, Vector4F vector)
 {
     return(Vector4F.Divide(scalar, vector));
 }
コード例 #18
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Subtracts a vector from a vector.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance.</param>
		/// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
		/// <remarks>
		///	result[i] = left[i] - right[i].
		/// </remarks>
		public static Vector4F Subtract(Vector4F left, Vector4F right)
		{
			return new Vector4F(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
		}
コード例 #19
0
ファイル: Matrix4F.cs プロジェクト: stenfalp/Sharp3D.Math
 /// <summary>
 /// Transforms a given vector by a matrix and put the result in a vector.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix4F"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3F"/> instance.</param>
 /// <param name="result">A <see cref="Vector3F"/> instance to hold the result.</param>
 public static void Transform(Matrix4F matrix, Vector4F vector, ref Vector3F result)
 {
     result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z) + matrix.M14;
     result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z) + matrix.M24;
     result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z) + matrix.M34;
 }
コード例 #20
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Subtracts a vector from a scalar and put the result into another vector.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A single-precision floating-point number.</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		/// <remarks>
		/// result[i] = vector[i] - scalar
		/// </remarks>
		public static void Subtract(Vector4F vector, float scalar, ref Vector4F result)
		{
			result.X = vector.X - scalar;
			result.Y = vector.Y - scalar;
			result.Z = vector.Z - scalar;
			result.W = vector.W - scalar;
		}
コード例 #21
0
ファイル: Controller.cs プロジェクト: azykise/olawork
        HandleResult Camera3DController_OnRightDraging(Point location, Point delta)
        {
            Vector3F lookatpt = m_current_view.getCamera().Direction;
            Vector3F postiton = m_current_view.getCamera().Position;

            Vector3F dir = lookatpt - postiton;
            Vector3F top = MathHelper.IsZero(dir.X) && MathHelper.IsZero(dir.Y) ? Vector3F.YAxis : Vector3F.ZAxis;

            Vector3F right = Vector3F.CrossProduct(dir, top);
            right.Normalize();
            Vector3F up = Vector3F.CrossProduct(right, dir);
            up.Normalize();

            QuaternionF q1 = QuaternionF.FromAxisAngle(right, delta.Y * -1.0f * m_rotate_speed);
            QuaternionF q2 = QuaternionF.FromAxisAngle(up, delta.X * -1.0f * m_rotate_speed);
            q1.Normalize();
            q2.Normalize();

            QuaternionF q = q1 * q2; q.Normalize();
            Matrix4F m = QuaternionF.QuaternionToMatrix(q);
            Vector4F v_rotate = new Vector4F(dir.X, dir.Y, dir.Z, 0);
            v_rotate = m * v_rotate;
            dir = new Vector3F(v_rotate.X, v_rotate.Y, v_rotate.Z);

            if (Focus || m_current_view.getCamera().Focus)
                m_current_view.getCamera().Position = lookatpt - dir;
            else
                m_current_view.getCamera().Direction = postiton + dir;

            return HandleResult.Done;
        }
コード例 #22
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Divides a scalar by a vector.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A scalar</param>
		/// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
		/// <remarks>
		/// result[i] = scalar / vector[i]
		/// </remarks>
		public static Vector4F Divide(float scalar, Vector4F vector)
		{
			return new Vector4F(scalar / vector.X, scalar / vector.Y, scalar / vector.Z, scalar / vector.W);
		}
コード例 #23
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Adds two vectors.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="w">A <see cref="Vector4F"/> instance.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns>
 public static Vector4F Add(Vector4F v, Vector4F w)
 {
     return(new Vector4F(v.X + w.X, v.Y + w.Y, v.Z + w.Z, v.W + w.W));
 }
コード例 #24
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Multiplies a vector by a scalar.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A single-precision floating-point number.</param>
		/// <returns>A new <see cref="Vector4F"/> containing the result.</returns>
		public static Vector4F Multiply(Vector4F vector, float scalar)
		{
			return new Vector4F(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar);
		}
コード例 #25
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Adds a vector and a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns>
 public static Vector4F Add(Vector4F v, float s)
 {
     return(new Vector4F(v.X + s, v.Y + s, v.Z + s, v.W + s));
 }
コード例 #26
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Tests whether two vectors are approximately equal using default tolerance value.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance.</param>
		/// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns>
		public static bool ApproxEqual(Vector4F left, Vector4F right)
		{
			return ApproxEqual(left, right, MathFunctions.EpsilonF);
		}
コード例 #27
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Subtracts a vector from a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="w">A <see cref="Vector4F"/> instance.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
 /// <remarks>
 ///	result[i] = v[i] - w[i].
 /// </remarks>
 public static Vector4F Subtract(Vector4F v, Vector4F w)
 {
     return(new Vector4F(v.X - w.X, v.Y - w.Y, v.Z - w.Z, v.W - w.W));
 }
コード例 #28
0
ファイル: Matrix4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Transforms a given vector by a matrix.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix4F"/> instance.</param>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <returns>A new <see cref="Vector4F"/> instance containing the result.</returns>
		public static Vector4F Transform(Matrix4F matrix, Vector4F vector)
		{
			return new Vector4F(
				(matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z) + (matrix.M14 * vector.W),
				(matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z) + (matrix.M24 * vector.W),
				(matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z) + (matrix.M34 * vector.W),
				(matrix.M41 * vector.X) + (matrix.M42 * vector.Y) + (matrix.M43 * vector.Z) + (matrix.M44 * vector.W));
		}
コード例 #29
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Subtracts a scalar from a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = v[i] - s
 /// </remarks>
 public static Vector4F Subtract(Vector4F v, float s)
 {
     return(new Vector4F(v.X - s, v.Y - s, v.Z - s, v.W - s));
 }
コード例 #30
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Divides a vector by a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = v[i] / s;
 /// </remarks>
 public static Vector4F operator /(Vector4F v, float s)
 {
     return(Vector4F.Divide(v, s));
 }
コード例 #31
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Subtracts a vector from a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = s - v[i]
 /// </remarks>
 public static Vector4F Subtract(float s, Vector4F v)
 {
     return(new Vector4F(s - v.X, s - v.Y, s - v.Z, s - v.W));
 }
コード例 #32
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Converts the specified string to its <see cref="Vector4F"/> equivalent.
		/// A return value indicates whether the conversion succeeded or failed.
		/// </summary>
		/// <param name="value">A string representation of a <see cref="Vector4F"/>.</param>
		/// <param name="result">
		/// When this method returns, if the conversion succeeded,
		/// contains a <see cref="Vector4F"/> representing the vector specified by <paramref name="value"/>.
		/// </param>
		/// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
		public static bool TryParse(string value, out Vector4F result)
		{
			Regex r = new Regex(@"\((?<x>.*),(?<y>.*),(?<z>.*),(?<w>.*)\)", RegexOptions.Singleline);
			Match m = r.Match(value);
			if (m.Success)
			{
				result = new Vector4F(
					float.Parse(m.Result("${x}")),
					float.Parse(m.Result("${y}")),
					float.Parse(m.Result("${z}")),
					float.Parse(m.Result("${w}"))
					);

				return true;
			}

			result = Vector4F.Zero;
			return false;
		}
コード例 #33
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Divides a vector by another vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector4F"/> instance.</param>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
 /// <remarks>
 ///	result[i] = u[i] / v[i].
 /// </remarks>
 public static Vector4F Divide(Vector4F u, Vector4F v)
 {
     return(new Vector4F(u.X / v.X, u.Y / v.Y, u.Z / v.Z, u.W / v.W));
 }
コード例 #34
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Adds a vector and a scalar.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A single-precision floating-point number.</param>
		/// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns>
		public static Vector4F Add(Vector4F vector, float scalar)
		{
			return new Vector4F(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar);
		}
コード例 #35
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Divides a vector by a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = v[i] / s;
 /// </remarks>
 public static Vector4F Divide(Vector4F v, float s)
 {
     return(new Vector4F(v.X / s, v.Y / s, v.Z / s, v.W / s));
 }
コード例 #36
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Adds a vector and a scalar and put the result into another vector.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A single-precision floating-point number.</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		public static void Add(Vector4F vector, float scalar, ref Vector4F result)
		{
			result.X = vector.X + scalar;
			result.Y = vector.Y + scalar;
			result.Z = vector.Z + scalar;
			result.W = vector.W + scalar;
		}
コード例 #37
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Divides a scalar by a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = s / v[i]
 /// </remarks>
 public static Vector4F Divide(float s, Vector4F v)
 {
     return(new Vector4F(s / v.X, s / v.Y, s / v.Z, s / v.W));
 }
コード例 #38
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Subtracts a scalar from a vector.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A single-precision floating-point number.</param>
		/// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
		/// <remarks>
		/// result[i] = vector[i] - scalar
		/// </remarks>
		public static Vector4F Subtract(Vector4F vector, float scalar)
		{
			return new Vector4F(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar);
		}
コード例 #39
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Multiplies a vector by a scalar.
 /// </summary>
 /// <param name="u">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector4F"/> containing the result.</returns>
 public static Vector4F Multiply(Vector4F u, float s)
 {
     return(new Vector4F(u.X * s, u.Y * s, u.Z * s, u.W * s));
 }
コード例 #40
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Subtracts a vector from a second vector and puts the result into a third vector.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		/// <remarks>
		///	result[i] = left[i] - right[i].
		/// </remarks>
		public static void Subtract(Vector4F left, Vector4F right, ref Vector4F result)
		{
			result.X = left.X - right.X;
			result.Y = left.Y - right.Y;
			result.Z = left.Z - right.Z;
			result.W = left.W - right.W;
		}
コード例 #41
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Calculates the dot product of two vectors.
 /// </summary>
 /// <param name="u">A <see cref="Vector4F"/> instance.</param>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <returns>The dot product value.</returns>
 public static float DotProduct(Vector4F u, Vector4F v)
 {
     return((u.X * v.X) + (u.Y * v.Y) + (u.Z * v.Z) + (u.W * v.W));
 }
コード例 #42
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Subtracts a scalar from a vector and put the result into another vector.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A single-precision floating-point number.</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		/// <remarks>
		/// result[i] = scalar - vector[i]
		/// </remarks>
		public static void Subtract(float scalar, Vector4F vector, ref Vector4F result)
		{
			result.X = scalar - vector.X;
			result.Y = scalar - vector.Y;
			result.Z = scalar - vector.Z;
			result.W = scalar - vector.W;
		}
コード例 #43
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Negates a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the negated values.</returns>
 public static Vector4F Negate(Vector4F v)
 {
     return(new Vector4F(-v.X, -v.Y, -v.Z, -v.W));
 }
コード例 #44
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Divides a vector by a scalar.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A scalar</param>
		/// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns>
		/// <remarks>
		/// result[i] = vector[i] / scalar;
		/// </remarks>
		public static Vector4F Divide(Vector4F vector, float scalar)
		{
			return new Vector4F(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar);
		}
コード例 #45
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Tests whether two vectors are approximately equal using default tolerance value.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="u">A <see cref="Vector4F"/> instance.</param>
 /// <returns>True if the two vectors are approximately equal; otherwise, False.</returns>
 public static bool ApproxEqual(Vector4F v, Vector4F u)
 {
     return(ApproxEqual(v, u, MathFunctions.EpsilonF));
 }
コード例 #46
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Divides a vector by another vector.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance.</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		/// <remarks>
		/// result[i] = left[i] / right[i]
		/// </remarks>
		public static void Divide(Vector4F left, Vector4F right, ref Vector4F result)
		{
			result.X = left.X / right.X;
			result.Y = left.Y / right.Y;
			result.Z = left.Z / right.Z;
			result.W = left.W / right.W;
		}
コード例 #47
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Negates the values of the vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the negated values.</returns>
 public static Vector4F operator -(Vector4F v)
 {
     return(Vector4F.Negate(v));
 }
コード例 #48
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Divides a scalar by a vector.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A scalar</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		/// <remarks>
		/// result[i] = scalar / vector[i]
		/// </remarks>
		public static void Divide(float scalar, Vector4F vector, ref Vector4F result)
		{
			result.X = scalar / vector.X;
			result.Y = scalar / vector.Y;
			result.Z = scalar / vector.Z;
			result.W = scalar / vector.W;
		}
コード例 #49
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Adds two vectors.
 /// </summary>
 /// <param name="u">A <see cref="Vector4F"/> instance.</param>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns>
 public static Vector4F operator +(Vector4F u, Vector4F v)
 {
     return(Vector4F.Add(u, v));
 }
コード例 #50
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Multiplies a vector by a scalar and put the result in another vector.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="scalar">A single-precision floating-point number.</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		public static void Multiply(Vector4F vector, float scalar, ref Vector4F result)
		{
			result.X = vector.X * scalar;
			result.Y = vector.Y * scalar;
			result.Z = vector.Z * scalar;
			result.W = vector.W * scalar;
		}
コード例 #51
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Adds a vector and a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns>
 public static Vector4F operator +(float s, Vector4F v)
 {
     return(Vector4F.Add(v, s));
 }
コード例 #52
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Negates a vector.
		/// </summary>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <returns>A new <see cref="Vector4F"/> instance containing the negated values.</returns>
		public static Vector4F Negate(Vector4F vector)
		{
			return new Vector4F(-vector.X, -vector.Y, -vector.Z, -vector.W);
		}
コード例 #53
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Subtracts a vector from a vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector4F"/> instance.</param>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
 /// <remarks>
 ///	result[i] = v[i] - w[i].
 /// </remarks>
 public static Vector4F operator -(Vector4F u, Vector4F v)
 {
     return(Vector4F.Subtract(u, v));
 }
コード例 #54
0
ファイル: Vector4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Tests whether two vectors are approximately equal given a tolerance value.
		/// </summary>
		/// <param name="left">A <see cref="Vector4F"/> instance.</param>
		/// <param name="right">A <see cref="Vector4F"/> instance.</param>
		/// <param name="tolerance">The tolerance value used to test approximate equality.</param>
		/// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns>
		public static bool ApproxEqual(Vector4F left, Vector4F right, float tolerance)
		{
			return
				(
				(System.Math.Abs(left.X - right.X) <= tolerance) &&
				(System.Math.Abs(left.Y - right.Y) <= tolerance) &&
				(System.Math.Abs(left.Z - right.Z) <= tolerance) &&
				(System.Math.Abs(left.W - right.W) <= tolerance)
				);
		}
コード例 #55
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Subtracts a vector from a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = v[i] - s
 /// </remarks>
 public static Vector4F operator -(Vector4F v, float s)
 {
     return(Vector4F.Subtract(v, s));
 }
コード例 #56
0
ファイル: Matrix4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Initializes a new instance of the <see cref="Matrix4F"/> structure with the specified values.
		/// </summary>
		/// <param name="column1">A <see cref="Vector4F"/> instance holding values for the first column.</param>
		/// <param name="column2">A <see cref="Vector4F"/> instance holding values for the second column.</param>
		/// <param name="column3">A <see cref="Vector4F"/> instance holding values for the third column.</param>
		/// <param name="column4">A <see cref="Vector4F"/> instance holding values for the fourth column.</param>
		public Matrix4F(Vector4F column1, Vector4F column2, Vector4F column3, Vector4F column4)
		{
			_m11 = column1.X; _m12 = column2.X; _m13 = column3.X; _m14 = column4.X;
			_m21 = column1.Y; _m22 = column2.Y; _m23 = column3.Y; _m24 = column4.Y;
			_m31 = column1.Z; _m32 = column2.Z; _m33 = column3.Z; _m34 = column4.Z;
			_m41 = column1.W; _m42 = column2.W; _m43 = column3.W; _m44 = column4.W;
		}
コード例 #57
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Subtracts a scalar from a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = s - v[i]
 /// </remarks>
 public static Vector4F operator -(float s, Vector4F v)
 {
     return(Vector4F.Subtract(s, v));
 }
コード例 #58
0
ファイル: Matrix4F.cs プロジェクト: TimVelo/StackBuilder
		/// <summary>
		/// Transforms a given vector by a matrix and put the result in a vector.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix4F"/> instance.</param>
		/// <param name="vector">A <see cref="Vector4F"/> instance.</param>
		/// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param>
		public static void Transform(Matrix4F matrix, Vector4F vector, ref Vector4F result)
		{
			result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z) + (matrix.M14 * vector.W);
			result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z) + (matrix.M24 * vector.W);
			result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z) + (matrix.M34 * vector.W);
			result.W = (matrix.M41 * vector.X) + (matrix.M42 * vector.Y) + (matrix.M43 * vector.Z) + (matrix.M44 * vector.W);
		}
コード例 #59
0
ファイル: Vector4F.cs プロジェクト: ekampf/Sharp3D.Math
 /// <summary>
 /// Multiplies a vector by a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector4F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector4F"/> containing the result.</returns>
 public static Vector4F operator *(float s, Vector4F v)
 {
     return(Vector4F.Multiply(v, s));
 }