daily update on 20240513 by nitload youmu, instancing render added
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public interface IVector
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix2x2.cs"
|
||||
// file="Matrix22.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix2x3.cs"
|
||||
// file="Matrix23.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -36,13 +36,13 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = ((3 + 2) * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix23:IMat
|
||||
public struct Matrix23 : IMat
|
||||
{
|
||||
|
||||
[FieldOffset(5 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
[FieldOffset(3 * 4 * sizeof(float))] internal Mat2 transpose;
|
||||
|
||||
[FieldOffset(0)] internal Mat3 mat;
|
||||
[FieldOffset(3 * 4 * sizeof(float))] internal Mat2 transpose;
|
||||
|
||||
internal Matrix23(
|
||||
Vector4 c0,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix2x4.cs"
|
||||
// file="Matrix24.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -36,13 +36,13 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = ((4 + 2) * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix24:IMat
|
||||
public struct Matrix24 : IMat
|
||||
{
|
||||
|
||||
[FieldOffset(6 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
[FieldOffset(4 * 4 * sizeof(float))] internal Mat2 transpose;
|
||||
|
||||
[FieldOffset(0)] internal Mat4 mat;
|
||||
[FieldOffset(4 * 4 * sizeof(float))] internal Mat2 transpose;
|
||||
|
||||
[FieldOffset(0)] public vec2d Colum0;
|
||||
[FieldOffset(16)] public vec2d Colum1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix3x2.cs"
|
||||
// file="Matrix32.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -36,16 +36,17 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = (5 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix32:IMat
|
||||
public struct Matrix32 : IMat
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal vec3d colum0;
|
||||
[FieldOffset(4 * 4)] internal vec3d colum1;
|
||||
[FieldOffset(5 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
[FieldOffset(0)] internal Mat2 mat;
|
||||
[FieldOffset(2 * 4 * sizeof(float))] internal Mat3 transpose;
|
||||
|
||||
[FieldOffset(0)] internal vec3d colum0;
|
||||
[FieldOffset(4 * 4)] internal vec3d colum1;
|
||||
|
||||
internal Matrix32(
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix3x3.cs"
|
||||
// file="Matrix33.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = (6 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix33:IMat
|
||||
public struct Matrix33 : IMat
|
||||
{
|
||||
|
||||
[FieldOffset(6 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix3x4.cs"
|
||||
// file="Matrix34.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -38,13 +38,13 @@ namespace StgSharp.Math
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = (7 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix34:IMat
|
||||
public struct Matrix34 : IMat
|
||||
{
|
||||
|
||||
[FieldOffset(7 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
[FieldOffset(4 * 4 * sizeof(float))] internal Mat3 transpose;
|
||||
|
||||
[FieldOffset(0)] internal Mat4 mat;
|
||||
[FieldOffset(4 * 4 * sizeof(float))] internal Mat3 transpose;
|
||||
|
||||
[FieldOffset(0 * 4 * sizeof(float))] public vec3d Colum0;
|
||||
[FieldOffset(1 * 4 * sizeof(float))] public vec3d Colum1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix4x2.cs"
|
||||
// file="Matrix42.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -39,7 +39,7 @@ namespace StgSharp.Math
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = ((16 + 8) * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix42:IMat
|
||||
public struct Matrix42 : IMat
|
||||
{
|
||||
|
||||
[FieldOffset((16 + 8) * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix4x3.cs"
|
||||
// file="Matrix43.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -37,7 +37,7 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = (7 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix43 : IEquatable<Matrix43>,IMat
|
||||
public struct Matrix43 : IEquatable<Matrix43>, IMat
|
||||
{
|
||||
|
||||
[FieldOffset(7 * 4 * sizeof(float))]
|
||||
|
||||
@@ -49,9 +49,9 @@ namespace StgSharp.Math
|
||||
|
||||
[FieldOffset(0)] internal Mat4 mat;
|
||||
[FieldOffset(16 * sizeof(float))] internal Mat4 transpose;
|
||||
[FieldOffset(0 * sizeof(float))] internal vec4d colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal vec4d colum1;
|
||||
[FieldOffset(8 * sizeof(float))] internal vec4d colum2;
|
||||
[FieldOffset(0 * sizeof(float))] internal vec4d colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal vec4d colum1;
|
||||
[FieldOffset(8 * sizeof(float))] internal vec4d colum2;
|
||||
[FieldOffset(12 * sizeof(float))] internal vec4d colum3;
|
||||
|
||||
internal Matrix44(Mat4 mat)
|
||||
@@ -151,6 +151,13 @@ namespace StgSharp.Math
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
public static Matrix44 WNegativeUnit
|
||||
=> new Matrix44(
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, -1
|
||||
);
|
||||
|
||||
public static Matrix44 XNegativeUnit
|
||||
=> new Matrix44(
|
||||
@@ -174,13 +181,6 @@ namespace StgSharp.Math
|
||||
0, 0, -1, 0,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
public static Matrix44 WNegativeUnit
|
||||
=> new Matrix44(
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, -1
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe float Det()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Linear.Cross.cs"
|
||||
// file="Vector.Cross.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Linear.GetAngle.cs"
|
||||
// file="Vector.GetAngle.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Linear.GetLength.cs"
|
||||
// file="Vector.GetLength.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Vector.Orthogonalize.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Data;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
|
||||
internal static partial class InternalIO
|
||||
{
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "normalize",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Normalize(M128* source, M128* target);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static partial class Linear
|
||||
{
|
||||
|
||||
public static vec4d Orthogonalize(vec4d vec)
|
||||
{
|
||||
return new vec4d { vec = Vector4.Normalize(vec.vec) };
|
||||
}
|
||||
public static vec3d Orthogonalize(vec3d vec)
|
||||
{
|
||||
return new vec3d { vec = Vector4.Normalize(vec.vec) };
|
||||
}
|
||||
public static unsafe void Orthogonalize(ref vec4d source, ref vec4d target)
|
||||
{
|
||||
Vector4 s = source.vec;
|
||||
Vector4 t = target.vec;
|
||||
|
||||
s = Vector4.Normalize(s);
|
||||
|
||||
float dotProduct = Vector4.Dot(s, t);
|
||||
Vector4 projection = Vector4.Multiply(s, t);
|
||||
|
||||
t -= projection;
|
||||
|
||||
source.vec = s;
|
||||
target.vec = t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Orthogonalize two <see cref="vec3d"/>s, let their length be 1
|
||||
/// and perpendicular to each other.
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="target"></param>
|
||||
public static unsafe void Orthogonalize(ref vec3d source, ref vec3d target)
|
||||
{
|
||||
Vector3 s = source.v;
|
||||
Vector3 t = target.v;
|
||||
|
||||
s = Vector3.Normalize(s);
|
||||
Vector3 projection = (Vector3.Dot(t, s) / Vector3.Dot(s, s)) * s;
|
||||
t -= projection;
|
||||
t = Vector3.Normalize(t);
|
||||
|
||||
source.v = s;
|
||||
target.v = t;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Linear.VectorTransform.cs"
|
||||
// file="Vector.VectorTransform.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace StgSharp
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region transpose
|
||||
|
||||
|
||||
@@ -93,9 +94,6 @@ namespace StgSharp.Math
|
||||
internal struct Mat2 : IEquatable<Mat2>
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal Vector4 colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal Vector4 colum1;
|
||||
|
||||
[FieldOffset(0 * sizeof(float))] internal float m00;
|
||||
[FieldOffset(4 * sizeof(float))] internal float m01;
|
||||
[FieldOffset(1 * sizeof(float))] internal float m10;
|
||||
@@ -105,6 +103,9 @@ namespace StgSharp.Math
|
||||
[FieldOffset(3 * sizeof(float))] internal float m30;
|
||||
[FieldOffset(7 * sizeof(float))] internal float m31;
|
||||
|
||||
[FieldOffset(0)] internal Vector4 colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal Vector4 colum1;
|
||||
|
||||
internal Mat2(
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace StgSharp
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region transpose
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "transpose3to4",
|
||||
@@ -77,10 +78,6 @@ namespace StgSharp.Math
|
||||
public struct Mat3 : IEquatable<Mat3>, IMat
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal Vector4 colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal Vector4 colum1;
|
||||
[FieldOffset(8 * sizeof(float))] internal Vector4 colum2;
|
||||
|
||||
[FieldOffset(0 * sizeof(float))] internal float m00;
|
||||
|
||||
[FieldOffset(4 * sizeof(float))] internal float m01;
|
||||
@@ -96,6 +93,10 @@ namespace StgSharp.Math
|
||||
[FieldOffset(7 * sizeof(float))] internal float m31;
|
||||
[FieldOffset(11 * sizeof(float))] internal float m32;
|
||||
|
||||
[FieldOffset(0)] internal Vector4 colum0;
|
||||
[FieldOffset(4 * sizeof(float))] internal Vector4 colum1;
|
||||
[FieldOffset(8 * sizeof(float))] internal Vector4 colum2;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return (obj is Mat3 mat) && Equals(mat);
|
||||
|
||||
@@ -36,20 +36,20 @@ namespace StgSharp.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// A two dimension vector defined by two elements.
|
||||
/// Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
/// Vec2Ds in StgSharp are default used as colum vector.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
|
||||
public struct vec2d
|
||||
public struct vec2d:IVector
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal unsafe fixed float num[2];
|
||||
|
||||
[FieldOffset(0)]
|
||||
internal Vector2 v;
|
||||
|
||||
[FieldOffset(0)]
|
||||
internal Vector4 vec;
|
||||
|
||||
[FieldOffset(0)] internal unsafe fixed float num[2];
|
||||
|
||||
[FieldOffset(0)]
|
||||
public float X;
|
||||
[FieldOffset(4)]
|
||||
@@ -120,6 +120,7 @@ namespace StgSharp.Math
|
||||
{
|
||||
return new vec2d(tuple.Item1, tuple.Item2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Vec2d
|
||||
@@ -128,5 +129,6 @@ namespace StgSharp.Math
|
||||
public static vec2d Unit => new vec2d(1, 1);
|
||||
|
||||
public static vec2d Zero => new vec2d(0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,18 +40,18 @@ using System.Security.AccessControl;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
|
||||
public struct vec3d : IEquatable<vec3d>
|
||||
public struct vec3d : IEquatable<vec3d>, IVector
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal unsafe fixed float num[3];
|
||||
[FieldOffset(0)]
|
||||
internal M128 reg;
|
||||
|
||||
[FieldOffset(0)]
|
||||
internal Vector3 v;
|
||||
|
||||
[FieldOffset(0)]
|
||||
internal Vector4 vec;
|
||||
[FieldOffset(0)]
|
||||
internal M128 reg;
|
||||
|
||||
[FieldOffset(0)] internal unsafe fixed float num[3];
|
||||
|
||||
[FieldOffset(0)] public float X;
|
||||
[FieldOffset(4)] public float Y;
|
||||
@@ -67,6 +67,12 @@ namespace StgSharp.Math
|
||||
v = vector;
|
||||
}
|
||||
|
||||
public vec3d(vec2d xy, float z)
|
||||
{
|
||||
vec = xy.vec;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public vec3d(
|
||||
float x, float y, float z)
|
||||
{
|
||||
@@ -76,20 +82,16 @@ namespace StgSharp.Math
|
||||
v = new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public vec3d Cross(vec3d right)
|
||||
public vec3d XYZ
|
||||
{
|
||||
return new vec3d(
|
||||
(this.Y * right.Z) - (this.Z * right.Y),
|
||||
(this.X * right.Z) - (this.Z * right.X),
|
||||
(this.X * right.Y) - (this.Y * right.X)
|
||||
);
|
||||
get { return new vec3d(v); }
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float Dot(vec3d right)
|
||||
{
|
||||
return Vector3.Dot(v,right.v);
|
||||
return Vector3.Dot(v, right.v);
|
||||
}
|
||||
|
||||
public bool Equals(vec3d other)
|
||||
@@ -178,20 +180,10 @@ namespace StgSharp.Math
|
||||
return new vec3d(vec.v / value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe implicit operator vec3d((float, float, float) tuple)
|
||||
{
|
||||
vec3d v = *(vec3d*)&tuple;
|
||||
v.vec.W = 0.0f;
|
||||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d operator +(vec3d left, vec3d right)
|
||||
{
|
||||
return new vec3d(
|
||||
left.vec + right.vec
|
||||
);
|
||||
return new vec3d(left.vec + right.vec);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -200,17 +192,25 @@ namespace StgSharp.Math
|
||||
return left.v == right.v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe implicit operator vec3d((float, float, float) tuple)
|
||||
{
|
||||
vec3d v = *(vec3d*)&tuple;
|
||||
v.vec.W = 0.0f;
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Vec3d
|
||||
{
|
||||
|
||||
public static bool IsParallel(vec3d left, vec3d right)
|
||||
{
|
||||
return Cross(left,right) == Zero;
|
||||
}
|
||||
public static vec3d One => new vec3d(1, 1, 1);
|
||||
public static vec3d UnitX => new vec3d(1, 0, 0);
|
||||
public static vec3d UnitY => new vec3d(0, 1, 0);
|
||||
|
||||
|
||||
public static vec3d UnitZ => new vec3d(0, 0, 1);
|
||||
public static vec3d Zero => new vec3d(0, 0, 0);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d Cross(vec3d left, vec3d right)
|
||||
@@ -218,11 +218,10 @@ namespace StgSharp.Math
|
||||
return Linear.Cross(left, right);
|
||||
}
|
||||
|
||||
public static vec3d One => new vec3d(1, 1, 1);
|
||||
public static vec3d Zero => new vec3d(0, 0, 0);
|
||||
public static bool IsParallel(vec3d left, vec3d right)
|
||||
{
|
||||
return Cross(left, right) == Zero;
|
||||
}
|
||||
|
||||
public static vec3d UnitZ => new vec3d(0, 0, 1);
|
||||
public static vec3d UnitX => new vec3d(1, 0, 0);
|
||||
public static vec3d UnitY => new vec3d(0, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user