daily update on 20230320 by nitload youmu

This commit is contained in:
Nitload
2023-03-20 01:45:49 +08:00
parent 167e33a3dd
commit db2ca36fd7
100 changed files with 1211 additions and 746 deletions
+4
View File
@@ -0,0 +1,4 @@
{
"masmtasm.ASM.assembler": "MASM",
"masmtasm.ASM.emulator": "msdos player"
}
+69 -15
View File
@@ -1,15 +1,69 @@
.386 ; 编译器指令,使用386指令集
.model flat, stdcall ; model汇编指令,程序的内存模式, flat是windows程序,没有远近指针,stdcall是windows函数用的参数方式,即参数从右向左传递
option casemap :none ; 标签是否区分大小写
include \masm32\include\windows.inc ; 包含了Win32 API 的一些常量和函数定义
include \masm32\include\kernel32.inc ; 包含了后面使用的ExitProcess函数
include \masm32\include\masm32.inc ; 包含了后面使用的StdOut函数,不是标准的Win32函数,由MASM提供
includelib \masm32\lib\kernel32.lib ; 库文件
includelib \masm32\lib\masm32.lib
.data
HelloWorld db "Hello World!", 0 ; 定义使用的字符串常量,db代表define byte。最后跟一个NUL,表示ANSI字符集结束符
.code ; 开始代码区
start: ; 所有的代码要在start标签后、end start前
invoke StdOut, addr HelloWorld ; 调用函数StdOut,参数量HelloWorld的地址。注意StdOut是MASM提供的宏。其它编辑器里可以使用WriteConsole之类win32函数代替。
invoke ExitProcess, 0 ; 调用ExitProcess
end start
; Attributes: bp-based frame fpd=1A0h
; int main(...)
main proc near
frame= byte ptr -1C0h
var_1A0= byte ptr -1A0h
var_19C= dword ptr -19Ch
var_178= dword ptr -178h
var_148= qword ptr -148h
var_120= xmmword ptr -120h
var_F0= xmmword ptr -0F0h
var_18= qword ptr -18h
; __unwind { // j___GSHandlerCheck
push rbp
push rdi
sub rsp, 1B8h
lea rbp, [rsp+20h]
__$EncStackInitStart:
lea rdi, [rsp+1C0h+var_1A0]
mov ecx, 36h ; '6'
mov eax, 0CCCCCCCCh
rep stosd
__$EncStackInitEnd:
mov rax, cs:__security_cookie
xor rax, rbp
mov [rbp+1A0h+var_18], rax
lea rcx, __41B3B322_AsmSqrt@c ; JMC_flag
call j___CheckForDebuggerJustMyCode
movss xmm0, cs:__real@40800000
movss [rbp+1A0h+var_19C], xmm0
lea rax, [rbp+1A0h+var_19C]
mov [rbp+1A0h+var_148], rax
mov rax, [rbp+1A0h+var_148]
movss xmm0, dword ptr [rax]
xorps xmm1, xmm1
movss xmm1, xmm0
movaps xmm0, xmm1
movaps [rbp+1A0h+var_120], xmm0
movaps xmm0, [rbp+1A0h+var_120]
sqrtss xmm0, xmm0
movaps [rbp+1A0h+var_F0], xmm0
movaps xmm0, [rbp+1A0h+var_F0]
movss [rbp+1A0h+var_178], xmm0
mov eax, 4
imul rax, 0
cvtss2sd xmm0, [rbp+rax+1A0h+var_178]
movaps xmm1, xmm0
movq rdx, xmm1
lea rcx, _Format ; "%f"
call j_printf
xor eax, eax
mov edi, eax
lea rcx, [rbp+1A0h+frame] ; frame
lea rdx, v ; v
call j__RTC_CheckStackVars
mov eax, edi
mov rcx, [rbp+1A0h+var_18]
xor rcx, rbp ; StackCookie
call j___security_check_cookie
lea rsp, [rbp+198h]
pop rdi
pop rbp
retn
; } // starts at 140011870
main endp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+10
View File
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcxproj", "{9C0FD617-CD38-48B5-A16C-909FBA56BBF5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project2", "Project2\Project2.vcxproj", "{3575C925-9280-4453-8D67-2BFD4E76A1D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -21,6 +23,14 @@ Global
{9C0FD617-CD38-48B5-A16C-909FBA56BBF5}.Release|x64.Build.0 = Release|x64
{9C0FD617-CD38-48B5-A16C-909FBA56BBF5}.Release|x86.ActiveCfg = Release|Win32
{9C0FD617-CD38-48B5-A16C-909FBA56BBF5}.Release|x86.Build.0 = Release|Win32
{3575C925-9280-4453-8D67-2BFD4E76A1D8}.Debug|x64.ActiveCfg = Debug|x64
{3575C925-9280-4453-8D67-2BFD4E76A1D8}.Debug|x64.Build.0 = Debug|x64
{3575C925-9280-4453-8D67-2BFD4E76A1D8}.Debug|x86.ActiveCfg = Debug|Win32
{3575C925-9280-4453-8D67-2BFD4E76A1D8}.Debug|x86.Build.0 = Debug|Win32
{3575C925-9280-4453-8D67-2BFD4E76A1D8}.Release|x64.ActiveCfg = Release|x64
{3575C925-9280-4453-8D67-2BFD4E76A1D8}.Release|x64.Build.0 = Release|x64
{3575C925-9280-4453-8D67-2BFD4E76A1D8}.Release|x86.ActiveCfg = Release|Win32
{3575C925-9280-4453-8D67-2BFD4E76A1D8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+27 -11
View File
@@ -5,27 +5,43 @@
void main()
{
float a = sseSqrt(4.0f);
int b = (int)a;
/*
float z = 4.00f;
float* a = &z;
float b = sseSqrt(z);
printf(b);
}
printf("%f", b);
/**/
float sseSqrt(float x)
{
float* pa = &x;
float result[4];
float a = 4.0f;
float r[4];
float* pa = &a;
__m128 b;
__m128 c;
b = _mm_load_ss(pa);
c = _mm_sqrt_ss(b);
_mm_store_ss(r, c);
printf("%f", r[0]);
/**/
}
/*
float sseSqrt(float x)
{
float* a = &x;
float result[4];
__m128 b = _mm_load_ss(a);
__m128 c = _mm_sqrt_ss(b);
_mm_store_ss(result, c);
return result[3];
}
return result[0];
}
/**/
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,2 @@
AsmSqrt.c
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\Math\C\Project1\Project1\AsmSqrt.c(8,12): warning C4013: “sseSqrt”未定义;假设外部返回 int
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\Math\C\Project1\Project1\AsmSqrt.c(12,10): warning C4047: “函数”:“const char *const ”与“int”的间接级别不同
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\Math\C\Project1\Project1\AsmSqrt.c(12,9): warning C4024: “printf”: 形参和实参 1 的类型不同
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\Math\C\Project1\Project1\AsmSqrt.c(8,12): warning C4244: “初始化”: 从“int”转换到“float”,可能丢失数据
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\Math\C\Project1\Project1\AsmSqrt.c(17,1): warning C4142: "sseSqrt": 类型的良性重定义
MSVCRTD.lib(exe_main.obj) : error LNK2019: 无法解析的外部符号 main,函数 "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) 中引用了该符号
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\Math\C\Project1\x64\Debug\Project1.exe : fatal error LNK1120: 1 个无法解析的外部命令
Project1.vcxproj -> D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\Math\C\Project1\x64\Debug\Project1.exe
Binary file not shown.
Binary file not shown.
+135
View File
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{3575c925-9280-4453-8d67-2bfd4e76a1d8}</ProjectGuid>
<RootNamespace>Project2</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="源.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="源.c">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
+16
View File
@@ -0,0 +1,16 @@
#include<stdio.h>
#include <xmmintrin.h>
#include <immintrin.h>
#include <intrin.h>
void main()
{
float a = 4.00f;
float* pa = &a;
_asm
(
MOVSS xmm1,%0
);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
View File
@@ -14,5 +14,8 @@ namespace StgSharp.Control
_cache.Next = default(StgSharp.ContainerNode<INode>);
_cache.Previous = default(StgSharp.ContainerNode<INode>);
}
}
}
-32
View File
@@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp
{
//对4字节空间的联合体的C#实现
[StructLayout(LayoutKind.Explicit, Size = 4)]
public struct Union4
{
[FieldOffset(0)]
public byte b0;
[FieldOffset(1)]
public byte b1;
[FieldOffset(2)]
public byte b2;
[FieldOffset(3)]
public byte b3;
//得到对应的int值
[FieldOffset(0)]
public uint i;
//得到对应的float值
[FieldOffset(0)]
public float f;
}
}
-30
View File
@@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp
{
//对8字节空间的联合体的C#实现
[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct Union8
{
[FieldOffset(0)]
public byte b0;
[FieldOffset(1)]
public byte b1;
[FieldOffset(2)]
public byte b2;
[FieldOffset(3)]
public byte b3;
//得到对应的int值
[FieldOffset(0)]
public int i1;
[FieldOffset(4)]
public int i2;
//得到对应的float值
[FieldOffset(0)]
public double f;
}
}
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Entities
{
internal class CollisionPartical
{
}
}
+11
View File
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Entities
{
public class Enemy : Entity
{
}
}
+71
View File
@@ -0,0 +1,71 @@
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public class Entity:INode<Entity>
{
internal vec2d _pos;
internal IGeometry _collisionBox;
internal Sensor<IGeometry> _collisionSensor;
internal ContainerNode<Entity> _id;
public IGeometry CollisionBox
{
get { return _collisionBox; }
set { _collisionBox = value; }
}
/// <summary>
/// A sensor used for cheking out if a bullet hit a player or something else
/// </summary>
public Sensor<IGeometry> CollisionSensor
{
get { return _collisionSensor; }
set { _collisionSensor = value; }
}
public string Texture { get; set; }
/// <summary>
/// A 2D vector presenting the position of an enemy entity, position can also be visited by X, Y
/// </summary>
public vec2d Location { get; }
/// <summary>
/// X position of an enenmy entity
/// </summary>
public float X { get; set; }
/// <summary>
/// Y position of an enemy entity
/// </summary>
public float Y { get; set; }
ContainerNode<Entity> INode<Entity>.ID
{
get { return _id; }
}
public void SetLocation(Point p)
{
}
void INode<Entity>.setID<T>(ContainerNode<T> id)
{
if (id == null)
{
_id = id as ContainerNode<Entity>;
}
else
{
throw new ArgumentException("Cannot set id twice!");
}
}
}
}
-20
View File
@@ -1,20 +0,0 @@
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public interface IEntity:INode
{
public IGeometry CollisionBox { get; set; }
public Sensor CollisionSensor { get; set; }
public string Texture { get; set; }
public Vec2D Location { get; }
public void SetLocation(Point p);
}
}
+1 -36
View File
@@ -5,43 +5,8 @@ using System.Text;
namespace StgSharp
{
public class Partical : IEntity
public class Partical : Entity
{
internal IGeometry _collisionBox;
internal Sensor _collisionSensor;
internal string _texture;
internal Vec2D _position;
IGeometry IEntity.CollisionBox
{
get { return _collisionBox; }
set { _collisionBox = value; }
}
Sensor IEntity.CollisionSensor
{
get { return _collisionSensor; }
set { _collisionSensor = value; }
}
string IEntity.Texture
{
get { return _texture; }
set { _texture = value; }
}
Vec2D IEntity.Location
{
get { return _position; }
}
ContainerNode<INode> INode.ID => throw new NotImplementedException();
void INode.setID<T>(ContainerNode<T> id)
{
throw new NotImplementedException();
}
void IEntity.SetLocation(StgSharp.Point p)
{
this._position = p._position;
}
}
}
+1 -51
View File
@@ -5,58 +5,8 @@ using System.Text;
namespace StgSharp
{
public class Player : IEntity
public class Player : Entity
{
internal IGeometry _collisionBox;
internal Sensor _collisionSensor;
internal string _texture;
internal Vec2D _position;
private ContainerNode<INode> _id;
IGeometry IEntity.CollisionBox
{
get { return this._collisionBox; }
set { this._collisionBox = value; }
}
Sensor IEntity.CollisionSensor
{
get { return this._collisionSensor; }
set { this._collisionSensor = value; }
}
string IEntity.Texture
{
get { return this._texture; }
set { this._texture = value; }
}
Vec2D IEntity.Location
{
get { return this._position; }
}
ContainerNode<INode> INode.ID
{
get { return _id; }
}
public void SetLocation(Point p)
{
throw new NotImplementedException();
}
void INode.setID<T>(ContainerNode<T> id)
{
if (id == null)
{
_id = id as ContainerNode<INode>;
}
else
{
throw new ArgumentException("Cannot set id twice!");
}
}
}
}
+6 -6
View File
@@ -10,16 +10,16 @@ using System.Text;
namespace StgSharp
{
public class Point: INode
public class Point: INode<Point>
{
internal StgSharp.ContainerNode<INode> _id;
internal StgSharp.ContainerNode<Point> _id;
internal Vec2D _position;
internal vec2d _position;
internal GetLocationHandler getXHandler;
internal GetLocationHandler getYHandler;
ContainerNode<INode> INode.ID
ContainerNode<Point> INode<Point>.ID
{
get { return this._id; }
}
@@ -34,11 +34,11 @@ namespace StgSharp
get { return this._position.Y; }
}
void INode.setID<T>(ContainerNode<T> id)
void INode<Point>.setID<T>(ContainerNode<T> id)
{
if (id == null)
{
_id = id as ContainerNode<INode>;
_id = id as ContainerNode<Point>;
}
else
{
@@ -7,24 +7,24 @@ namespace StgSharp.Math
public static unsafe partial class Vector
{
public static float Det(Matrix2x2 array)
public static float Det(matrix2x2 array)
{
return Cross(array.row1,array.row2);
}
public static unsafe float Det(Matrix3x3 array)
public static unsafe float Det(matrix3x3 array)
{
float* p = &array.row1.X;
Matrix2x2 matrix1 = new Matrix2x2(
matrix2x2 matrix1 = new matrix2x2(
*(p + 4), *(p + 5),
*(p + 7), *(p + 8)
);
Matrix2x2 matrix2 = new Matrix2x2(
matrix2x2 matrix2 = new matrix2x2(
*(p + 3), *(p + 5),
*(p + 6), *(p + 8)
);
Matrix2x2 matrix3 = new Matrix2x2(
matrix2x2 matrix3 = new matrix2x2(
*(p + 3), *(p + 4),
*(p + 6), *(p + 7)
);
@@ -6,7 +6,7 @@ namespace StgSharp.Math
{
public static unsafe partial class Vector
{
public static float GetAngle(Vec2D vec1, Vec2D vec2)
public static float GetAngle(vec2d vec1, vec2d vec2)
{
return Calc.ACos(
vec1 .multiple(vec2)
@@ -14,7 +14,7 @@ namespace StgSharp.Math
);
}
public static float GetAngle(Vec3D vec1, Vec3D vec2)
public static float GetAngle(vec3d vec1, vec3d vec2)
{
return Calc.ACos(
vec1 * vec2
@@ -6,7 +6,7 @@ namespace StgSharp.Math
{
public static unsafe partial class Vector
{
public static float GetLength(this Vec3D vec)
public static float GetLength(this vec3d vec)
{
return Calc.Sqrt(
vec.X * vec.X +
@@ -15,7 +15,7 @@ namespace StgSharp.Math
);
}
public static float GetLength(this Vec2D vec)
public static float GetLength(this vec2d vec)
{
return Calc.Sqrt(
vec.X * vec.X +
@@ -7,7 +7,7 @@ namespace StgSharp.Math
public static unsafe partial class Vector
{
/*
public static Vec2D GetVector(Vec4D pointPair)
public static vec2d GetVector( vec4d pointPair)
{
return pointPair.Point2-pointPair.Point1;
}
@@ -13,9 +13,9 @@ namespace StgSharp.Math
/// <param name="colum"></param>
/// <param name="vec"></param>
/// <returns></returns>
public static Matrix2x2 multiple(this Colum2D colum, Vec2D vec)
public static matrix2x2 multiple(this colum2 colum, vec2d vec)
{
return new Matrix2x2(
return new matrix2x2(
colum.X * vec.X, colum.X * vec.Y,
colum.Y * vec.X, colum.Y * vec.Y
);
@@ -27,7 +27,7 @@ namespace StgSharp.Math
/// <param name="vec1"></param>
/// <param name="vec2"></param>
/// <returns></returns>
public static float multiple(this Vec2D vec1, Vec2D vec2)
public static float multiple(this vec2d vec1, vec2d vec2)
{
return vec1.X * vec2.X + vec1.Y * vec2.Y;
}
@@ -38,7 +38,7 @@ namespace StgSharp.Math
/// <param name="vec"></param>
/// <param name="colum"></param>
/// <returns></returns>
public static float multiple(this Vec2D vec, Colum2D colum)
public static float multiple(this vec2d vec, colum2 colum)
{
return vec.X * colum.X + vec.Y * colum.Y;
}
@@ -49,15 +49,15 @@ namespace StgSharp.Math
/// <param name="vec"></param>
/// <param name="matrix"></param>
/// <returns></returns>
public static unsafe Vec2D multiple(this Vec2D vec, Matrix2x2 matrix)
public static unsafe vec2d multiple(this vec2d vec, matrix2x2 matrix)
{
return new Vec2D(
return new vec2d(
vec.X * matrix.row1.X + vec.Y * matrix.row2.X,
vec.X * matrix.row1.Y + vec.Y * matrix.row2.Y
);
}
public static float multiple(this Vec3D vec, Colum3D colum)
public static float multiple(this vec3d vec, colum3 colum)
{
return vec.X * colum.X + vec.Y * colum.Y + vec.Z * colum.Z;
}
@@ -68,11 +68,11 @@ namespace StgSharp.Math
/// <param name="vec"></param>
/// <param name="matrix"></param>
/// <returns></returns>
public static unsafe Vec3D multiple(this Vec2D vec, Matrix2x3 matrix)
public static unsafe vec3d multiple(this vec2d vec, matrix2x3 matrix)
{
float* p = &matrix.row1.X;
return new Vec3D(
return new vec3d(
vec.X * *(p + 0) + vec.Y * *(p + 3),
vec.X * *(p + 1) + vec.Y * *(p + 4),
vec.X * *(p + 2) + vec.Y * *(p + 5)
@@ -85,11 +85,11 @@ namespace StgSharp.Math
/// <param name="vec"></param>
/// <param name="matrix"></param>
/// <returns></returns>
public static unsafe Vec4D multiple(this Vec2D vec, Matrix2x4 matrix)
public static unsafe vec4d multiple(this vec2d vec, matrix2x4 matrix)
{
float* p = &matrix.row1.X;
return new Vec4D(
return new vec4d(
vec.X * *(p + 0) + vec.Y * *(p + 4),
vec.X * *(p + 1) + vec.Y * *(p + 5),
vec.X * *(p + 2) + vec.Y * *(p + 6),
@@ -97,7 +97,7 @@ namespace StgSharp.Math
);
}
public static unsafe float multiple(this Vec4D vec, Colum4D colum)
public static unsafe float multiple(this vec4d vec, colum4 colum)
{
return vec.X * colum.X + vec.Y * colum.Y + vec.Z * colum.W + vec.W * colum.W;
}
@@ -108,12 +108,12 @@ namespace StgSharp.Math
/// <param name="matrix"></param>
/// <param name="colum"></param>
/// <returns></returns>
public static unsafe Colum2D multiple(this Matrix2x2 matrix, Colum2D colum)
public static unsafe colum2 multiple(this matrix2x2 matrix, colum2 colum)
{
float* p1 = &matrix.row1.X;
float* p2 = &colum.X;
return new Colum2D(
return new colum2(
*(p1 + 0) * *(p2 + 0) + *(p1 + 1) * *(p2 + 1),
*(p1 + 2) * *(p2 + 0) + *(p1 + 3) * *(p2 + 1)
);
@@ -125,7 +125,7 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x2 multiple(this Matrix2x2 matrix1, Matrix2x2 matrix2)
public static unsafe matrix2x2 multiple(this matrix2x2 matrix1, matrix2x2 matrix2)
{
float* a11 = &matrix1.row1.X;
float* a12 = &matrix1.row1.Y;
@@ -163,7 +163,7 @@ namespace StgSharp.Math
var u6 = u3 - m4;
var u7 = u3 + m5;
return new Matrix2x2(u1, u5, u6, u7);
return new matrix2x2(u1, u5, u6, u7);
}
@@ -173,7 +173,7 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x3 multiple(this Matrix2x2 matrix1, Matrix2x3 matrix2)
public static unsafe matrix2x3 multiple(this matrix2x2 matrix1, matrix2x3 matrix2)
{
float* p1 = &matrix1.row1.X;
@@ -184,10 +184,10 @@ namespace StgSharp.Math
float a21 = *(p1 + 2);
float a22 = *(p1 + 3);
Vec2D b11 = new Vec2D(*(p2 + 0), *(p2 + 1));
Vec2D b12 = new Vec2D(*(p2 + 2), 0);
Vec2D b21 = new Vec2D(*(p2 + 3), *(p2 + 4));
Vec2D b22 = new Vec2D(*(p2 + 5), 0);
vec2d b11 = new vec2d(*(p2 + 0), *(p2 + 1));
vec2d b12 = new vec2d(*(p2 + 2), 0);
vec2d b21 = new vec2d(*(p2 + 3), *(p2 + 4));
vec2d b22 = new vec2d(*(p2 + 5), 0);
var s1 = a21 + a22;
var s2 = s1 - a11;
@@ -215,7 +215,7 @@ namespace StgSharp.Math
var u6 = u3 - m4;
var u7 = u3 + m5;
return new Matrix2x3(
return new matrix2x3(
u1.X, u1.Y, u5.X,
u6.X, u6.Y, u7.X
);
@@ -228,7 +228,7 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x4 multiple(this Matrix2x2 matrix1, Matrix2x4 matrix2)
public static unsafe matrix2x4 multiple(this matrix2x2 matrix1, matrix2x4 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
@@ -238,10 +238,10 @@ namespace StgSharp.Math
float a21 = *(p1 + 2);
float a22 = *(p1 + 3);
Vec2D b11 = new Vec2D(*(p2 + 0), *(p2 + 1));
Vec2D b12 = new Vec2D(*(p2 + 2), *(p2 + 3));
Vec2D b21 = new Vec2D(*(p2 + 4), *(p2 + 5));
Vec2D b22 = new Vec2D(*(p2 + 6), *(p2 + 7));
vec2d b11 = new vec2d(*(p2 + 0), *(p2 + 1));
vec2d b12 = new vec2d(*(p2 + 2), *(p2 + 3));
vec2d b21 = new vec2d(*(p2 + 4), *(p2 + 5));
vec2d b22 = new vec2d(*(p2 + 6), *(p2 + 7));
var s1 = a21 + a22;
var s2 = s1 - a11;
@@ -269,7 +269,7 @@ namespace StgSharp.Math
var u6 = u3 - m4;
var u7 = u3 + m5;
return new Matrix2x4(
return new matrix2x4(
u1.X, u1.Y, u5.X, u5.Y,
u6.X, u6.Y, u7.X, u7.Y
);
@@ -281,9 +281,9 @@ namespace StgSharp.Math
/// <param name="matrix"></param>
/// <param name="vec"></param>
/// <returns></returns>
public static unsafe Colum2D multiple(this Matrix2x3 matrix, Colum3D vec)
public static unsafe colum2 multiple(this matrix2x3 matrix, colum3 vec)
{
return new Colum2D(
return new colum2(
matrix.row1.X * vec.X + matrix.row1.Y * vec.Y + matrix.row1.Z * vec.Z,
matrix.row2.X * vec.X + matrix.row2.Y * vec.Y + matrix.row2.Z * vec.Z
);
@@ -295,16 +295,16 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x2 multiple(this Matrix2x3 matrix1, Matrix3x2 matrix2)
public static unsafe matrix2x2 multiple(this matrix2x3 matrix1, matrix3x2 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
Matrix2x2 a1 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
Colum2D a2 = new Colum2D(*(p1 + 2), *(p1 + 5));
matrix2x2 a1 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
colum2 a2 = new colum2(*(p1 + 2), *(p1 + 5));
Matrix2x2 b1 = new Matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 2), *(p2 + 3));
Vec2D b2 = new Vec2D(*(p2 + 4), *(p2 + 5));
matrix2x2 b1 = new matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 2), *(p2 + 3));
vec2d b2 = new vec2d(*(p2 + 4), *(p2 + 5));
return a1.multiple(b1) + a2.multiple(b2);
}
@@ -315,23 +315,23 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x3 multiple(this Matrix2x3 matrix1, Matrix3x3 matrix2)
public static unsafe matrix2x3 multiple(this matrix2x3 matrix1, matrix3x3 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
var a1 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a2 = new Colum2D(*(p1 + 2), *(p1 + 5));
var a1 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a2 = new colum2(*(p1 + 2), *(p1 + 5));
var b11 = new Matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4));
var b12 = new Colum2D(*(p2 + 2), *(p2 + 5));
var b21 = new Vec2D(*(p2 + 6), *(p2 + 7));
var b11 = new matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4));
var b12 = new colum2(*(p2 + 2), *(p2 + 5));
var b21 = new vec2d(*(p2 + 6), *(p2 + 7));
var b22 = *(p2 + 8);
var c1 = a1.multiple(b11) + a2.multiple(b21);
var c2 = a1.multiple(b12) + a2 * b22;
return new Matrix2x3(
return new matrix2x3(
c1.row1.X, c1.row1.Y, c2.X,
c1.row2.X, c1.row2.Y, c2.Y
);
@@ -343,31 +343,31 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x4 multiple(this Matrix2x3 matrix1, Matrix3x4 matrix2)
public static unsafe matrix2x4 multiple(this matrix2x3 matrix1, matrix3x4 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
var a1 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a2 = new Colum2D(*(p1 + 2), *(p1 + 5));
var a1 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a2 = new colum2(*(p1 + 2), *(p1 + 5));
var b11 = new Matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 4), *(p2 + 5));
var b12 = new Matrix2x2(*(p2 + 2), *(p2 + 3), *(p2 + 6), *(p2 + 7));
var b21 = new Vec2D(*(p2 + 8), *(p2 + 9));
var b22 = new Vec2D(*(p2 + 10), *(p2 + 11));
var b11 = new matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 4), *(p2 + 5));
var b12 = new matrix2x2(*(p2 + 2), *(p2 + 3), *(p2 + 6), *(p2 + 7));
var b21 = new vec2d(*(p2 + 8), *(p2 + 9));
var b22 = new vec2d(*(p2 + 10), *(p2 + 11));
var c1 = a1.multiple(b11) + a2.multiple(b21);
var c2 = a1.multiple(b12) + a2.multiple(b22);
return new Matrix2x4(
new Vec4D(c1.row1,c2.row1),
new Vec4D(c1.row2,c2.row2)
return new matrix2x4(
new vec4d(c1.row1,c2.row1),
new vec4d(c1.row2,c2.row2)
);
}
public static unsafe Colum2D multiple(this Matrix2x4 matrix, Colum4D colum)
public static unsafe colum2 multiple(this matrix2x4 matrix, colum4 colum)
{
return new Colum2D(
return new colum2(
matrix.row1.multiple(colum),
matrix.row2.multiple(colum)
);
@@ -379,20 +379,20 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x2 multiple(this Matrix2x4 matrix1, Matrix4x2 matrix2)
public static unsafe matrix2x2 multiple(this matrix2x4 matrix1, matrix4x2 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
Vec2D a11 = new Vec2D(*(p1 + 0), *(p1 + 1));
Vec2D a12 = new Vec2D(*(p1 + 2), *(p1 + 3));
Vec2D a21 = new Vec2D(*(p1 + 4), *(p1 + 5));
Vec2D a22 = new Vec2D(*(p1 + 6), *(p1 + 7));
vec2d a11 = new vec2d(*(p1 + 0), *(p1 + 1));
vec2d a12 = new vec2d(*(p1 + 2), *(p1 + 3));
vec2d a21 = new vec2d(*(p1 + 4), *(p1 + 5));
vec2d a22 = new vec2d(*(p1 + 6), *(p1 + 7));
Colum2D b11 = new Colum2D(*(p2 + 0), *(p2 + 2));
Colum2D b12 = new Colum2D(*(p2 + 1), *(p2 + 3));
Colum2D b21 = new Colum2D(*(p2 + 4), *(p2 + 6));
Colum2D b22 = new Colum2D(*(p2 + 5), *(p2 + 7));
colum2 b11 = new colum2(*(p2 + 0), *(p2 + 2));
colum2 b12 = new colum2(*(p2 + 1), *(p2 + 3));
colum2 b21 = new colum2(*(p2 + 4), *(p2 + 6));
colum2 b22 = new colum2(*(p2 + 5), *(p2 + 7));
var s1 = a21 + a22;
var s2 = s1 - a11;
@@ -420,7 +420,7 @@ namespace StgSharp.Math
var u6 = u3 - m4;
var u7 = u3 + m5;
return new Matrix2x2(u1, u5, u6, u7);
return new matrix2x2(u1, u5, u6, u7);
}
/// <summary>
@@ -429,12 +429,12 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x3 multiple(this Matrix2x4 matrix1, Matrix4x3 matrix2)
public static unsafe matrix2x3 multiple(this matrix2x4 matrix1, matrix4x3 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
return new Matrix2x3(
return new matrix2x3(
getMatrixMember(p1,p2), getMatrixMember(p1, p2+1), getMatrixMember(p1, p2+2),
getMatrixMember(p1+4, p2), getMatrixMember(p1+4, p2+1), getMatrixMember(p1+4, p2 + 2)
);
@@ -459,29 +459,29 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix2x4 multiple(this Matrix2x4 matrix1, Matrix4x4 matrix2)
public static unsafe matrix2x4 multiple(this matrix2x4 matrix1, matrix4x4 matrix2)
{
Matrix2x2 a1 = new Matrix2x2(matrix1.row1.Point1,matrix1.row2.Point1);
Matrix2x2 a2 = new Matrix2x2(matrix1.row1.Point2, matrix1.row2.Point2);
matrix2x2 a1 = new matrix2x2(matrix1.row1.Point1,matrix1.row2.Point1);
matrix2x2 a2 = new matrix2x2(matrix1.row1.Point2, matrix1.row2.Point2);
Matrix2x2 b11 = new Matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
Matrix2x2 b12 = new Matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
Matrix2x2 b21 = new Matrix2x2(matrix2.row3.Point1, matrix2.row4.Point1);
Matrix2x2 b22 = new Matrix2x2(matrix2.row3.Point2, matrix2.row4.Point2);
matrix2x2 b11 = new matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
matrix2x2 b12 = new matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
matrix2x2 b21 = new matrix2x2(matrix2.row3.Point1, matrix2.row4.Point1);
matrix2x2 b22 = new matrix2x2(matrix2.row3.Point2, matrix2.row4.Point2);
var c1 = a1.multiple(b11) + a2.multiple(b21);
var c2 = a1.multiple(b12) + a2.multiple(b22);
return new Matrix2x4(
new Vec4D(c1.row1, c2.row1),
new Vec4D(c1.row2, c2.row2));
return new matrix2x4(
new vec4d(c1.row1, c2.row1),
new vec4d(c1.row2, c2.row2));
}
public static unsafe Colum3D multiple(this Matrix3x2 matrix, Colum2D colum)
public static unsafe colum3 multiple(this matrix3x2 matrix, colum2 colum)
{
return new Colum3D(
return new colum3(
matrix.row1.multiple(colum),
matrix.row1.multiple(colum),
matrix.row1.multiple(colum)
@@ -494,14 +494,14 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix3x2 multiple(this Matrix3x2 matrix1, Matrix2x2 matrix2)
public static unsafe matrix3x2 multiple(this matrix3x2 matrix1, matrix2x2 matrix2)
{
var a1 = new Matrix2x2(matrix1.row1, matrix1.row2);
var a1 = new matrix2x2(matrix1.row1, matrix1.row2);
var a2 = matrix1.row3;
var c1 = a1.multiple(matrix2);
return new Matrix3x2(
return new matrix3x2(
c1.row1, c1.row2, a2.multiple(matrix2)
);
}
@@ -512,16 +512,16 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix3x3 multiple(this Matrix3x2 matrix1, Matrix2x3 matrix2)
public static unsafe matrix3x3 multiple(this matrix3x2 matrix1, matrix2x3 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
Matrix2x2 a1 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 2), *(p1 + 3));
Vec2D a2 = new Vec2D(*(p1 + 4), *(p1 + 5));
matrix2x2 a1 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 2), *(p1 + 3));
vec2d a2 = new vec2d(*(p1 + 4), *(p1 + 5));
Matrix2x2 b1 = new Matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4));
Colum2D b2 = new Colum2D(*(p2 + 2), *(p2 + 5));
matrix2x2 b1 = new matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4));
colum2 b2 = new colum2(*(p2 + 2), *(p2 + 5));
var m11 = a1.multiple(b1);
var m12 = a1.multiple(b2);
@@ -530,7 +530,7 @@ namespace StgSharp.Math
float* p3 = &m11.row1.X;
return new Matrix3x3(
return new matrix3x3(
*(p3 + 0), *(p3 + 1),m12.X,
*(p3 + 2), *(p3 + 3),m12.Y,
m21.X, m21.Y, m22
@@ -543,29 +543,29 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix3x4 multiple(this Matrix3x2 matrix1, Matrix2x4 matrix2)
public static unsafe matrix3x4 multiple(this matrix3x2 matrix1, matrix2x4 matrix2)
{
var a1 = new Matrix2x2(matrix1.row1,matrix1.row2);
var a1 = new matrix2x2(matrix1.row1,matrix1.row2);
var a2 = matrix1.row3;
var b1 = new Matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
var b2 = new Matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
var b1 = new matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
var b2 = new matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
var c11 = a1.multiple(b1);
var c12 = a1.multiple(b2);
var c21 = a2.multiple(b1);
var c22 = a2.multiple(b2);
return new Matrix3x4(
new Vec4D(c11.row1, c12.row1),
new Vec4D(c11.row2, c12.row2),
new Vec4D(c21, c22)
return new matrix3x4(
new vec4d(c11.row1, c12.row1),
new vec4d(c11.row2, c12.row2),
new vec4d(c21, c22)
);
}
public static unsafe Colum3D multiple(this Matrix3x3 matrix, Colum3D colum)
public static unsafe colum3 multiple(this matrix3x3 matrix, colum3 colum)
{
return new Colum3D(
return new colum3(
matrix.row1.multiple(colum),
matrix.row2.multiple(colum),
matrix.row3.multiple(colum)
@@ -578,22 +578,22 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix3x2 multiple(this Matrix3x3 matrix1, Matrix3x2 matrix2)
public static unsafe matrix3x2 multiple(this matrix3x3 matrix1, matrix3x2 matrix2)
{
float* p1 = &matrix1.row1.X;
var a11 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new Colum2D(*(p1 + 2), *(p1 + 5));
var a21 = new Vec2D(*(p1 + 6), *(p1 + 7));
var a11 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new colum2(*(p1 + 2), *(p1 + 5));
var a21 = new vec2d(*(p1 + 6), *(p1 + 7));
var a22 = *(p1 + 8);
var b1 = new Matrix2x2(matrix2.row1,matrix2.row2);
var b1 = new matrix2x2(matrix2.row1,matrix2.row2);
var b2 = matrix2.row3;
var c1 = a11.multiple(b1) + a12.multiple(b2);
var c2 = a21.multiple(b1) + b2 * a22;
return new Matrix3x2(c1.row1,c1.row2,c2);
return new matrix3x2(c1.row1,c1.row2,c2);
}
/// <summary>
@@ -602,19 +602,19 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix3x3 multiple(this Matrix3x3 matrix1, Matrix3x3 matrix2)
public static unsafe matrix3x3 multiple(this matrix3x3 matrix1, matrix3x3 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
Matrix2x2 a11 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
Colum2D a12 = new Colum2D(*(p1 + 2), *(p1 + 5));
Vec2D a21 = new Vec2D(*(p1 + 6), *(p1 + 7));
matrix2x2 a11 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
colum2 a12 = new colum2(*(p1 + 2), *(p1 + 5));
vec2d a21 = new vec2d(*(p1 + 6), *(p1 + 7));
float a22 = *(p1 + 8);
Matrix2x2 b11 = new Matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4));
Colum2D b12 = new Colum2D(*(p2 + 2), *(p2 + 5));
Vec2D b21 = new Vec2D(*(p2 + 6), *(p2 + 7));
matrix2x2 b11 = new matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4));
colum2 b12 = new colum2(*(p2 + 2), *(p2 + 5));
vec2d b21 = new vec2d(*(p2 + 6), *(p2 + 7));
float b22 = *(p2 + 8);
var c11 = a11.multiple(b11) + a12.multiple(b21);
@@ -624,25 +624,25 @@ namespace StgSharp.Math
float* p = &(c11.row1.X);
return new Matrix3x3(
return new matrix3x3(
*(p + 0), *(p + 1), c12.X,
*(p + 2), *(p + 3), c12.Y,
c21.X, c21.Y, c22
);
}
public static unsafe Matrix3x4 multiple(this Matrix3x3 matrix1, Matrix3x4 matrix2)
public static unsafe matrix3x4 multiple(this matrix3x3 matrix1, matrix3x4 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
var a11 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new Colum2D(*(p1 + 2), *(p1 + 5));
var a21 = new Vec2D(*(p1 + 6), *(p1 + 7));
var a11 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new colum2(*(p1 + 2), *(p1 + 5));
var a21 = new vec2d(*(p1 + 6), *(p1 + 7));
var a22 = *(p1 + 8);
var b11 = new Matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
var b12 = new Matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
var b11 = new matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
var b12 = new matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
var b21 = matrix2.row3.Point1;
var b22 = matrix2.row3.Point2;
@@ -652,17 +652,17 @@ namespace StgSharp.Math
var c22 = a21.multiple(b12) + b22 * a22;
return new Matrix3x4(
new Vec4D(c11.row1,c12.row1),
new Vec4D(c11.row2,c12.row2),
new Vec4D(c21,c22)
return new matrix3x4(
new vec4d(c11.row1,c12.row1),
new vec4d(c11.row2,c12.row2),
new vec4d(c21,c22)
);
}
public static unsafe Colum3D multiple(this Matrix3x4 matrix, Colum4D colum)
public static unsafe colum3 multiple(this matrix3x4 matrix, colum4 colum)
{
return new Colum3D(
return new colum3(
matrix.row1.multiple(colum),
matrix.row2.multiple(colum),
matrix.row3.multiple(colum)
@@ -675,23 +675,23 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix3x2 multiple(this Matrix3x4 matrix1, Matrix4x2 matrix2)
public static unsafe matrix3x2 multiple(this matrix3x4 matrix1, matrix4x2 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
Matrix2x2 a11 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 4), *(p1 + 5));
Matrix2x2 a12 = new Matrix2x2(*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7));
Vec2D a21 = new Vec2D(*(p1 + 8), *(p1 + 9));
Vec2D a22 = new Vec2D(*(p1 + 10), *(p1 + 11));
matrix2x2 a11 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 4), *(p1 + 5));
matrix2x2 a12 = new matrix2x2(*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7));
vec2d a21 = new vec2d(*(p1 + 8), *(p1 + 9));
vec2d a22 = new vec2d(*(p1 + 10), *(p1 + 11));
Matrix2x2 b1 = new Matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 2), *(p2 + 3));
Matrix2x2 b2 = new Matrix2x2(*(p2 + 4), *(p2 + 5), *(p2 + 6), *(p2 + 7));
matrix2x2 b1 = new matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 2), *(p2 + 3));
matrix2x2 b2 = new matrix2x2(*(p2 + 4), *(p2 + 5), *(p2 + 6), *(p2 + 7));
var c1 = a11.multiple(b1) + a12.multiple(b2);
var c2 = a21.multiple(b1) + a22.multiple(b2);
return new Matrix3x2(c1.row1,c1.row2,c2);
return new matrix3x2(c1.row1,c1.row2,c2);
}
/// <summary>
@@ -700,28 +700,28 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix3x3 multiple(this Matrix3x4 matrix1, Matrix4x3 matrix2)
public static unsafe matrix3x3 multiple(this matrix3x4 matrix1, matrix4x3 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
Matrix2x2 a11 = new Matrix2x2(
matrix2x2 a11 = new matrix2x2(
*(p1 + 0), *(p1 + 1), *(p1 + 4), *(p1 + 5)
);
Matrix2x2 a12 = new Matrix2x2(
matrix2x2 a12 = new matrix2x2(
*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7)
);
Vec2D a21 = new Vec2D(*(p1 + 8), *(p1 + 9));
Vec2D a22 = new Vec2D(*(p1 + 10), *(p1 + 11));
vec2d a21 = new vec2d(*(p1 + 8), *(p1 + 9));
vec2d a22 = new vec2d(*(p1 + 10), *(p1 + 11));
Matrix2x2 b11 = new Matrix2x2(
matrix2x2 b11 = new matrix2x2(
*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4)
);
Colum2D b12 = new Colum2D(*(p2 + 2), *(p2 + 5));
Matrix2x2 b21 = new Matrix2x2(
colum2 b12 = new colum2(*(p2 + 2), *(p2 + 5));
matrix2x2 b21 = new matrix2x2(
*(p2 + 6), *(p2 + 7), *(p2 + 9), *(p2 + 10)
);
Colum2D b22 = new Colum2D(*(p2 + 8), *(p2 + 11));
colum2 b22 = new colum2(*(p2 + 8), *(p2 + 11));
var c11 = a11.multiple(b11) + a12.multiple(b21);
var c12 = a11.multiple(b12) + a12.multiple(b22);
@@ -730,7 +730,7 @@ namespace StgSharp.Math
float* pc1 = &c11.row1.X;
return new Matrix3x3(
return new matrix3x3(
*(pc1 + 0), *(pc1 + 1), c12.X,
*(pc1 + 2), *(pc1 + 3), c12.Y,
c21.X, c21.Y, c22
@@ -743,41 +743,41 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix3x4 multiple(this Matrix3x4 matrix1, Matrix4x4 matrix2)
public static unsafe matrix3x4 multiple(this matrix3x4 matrix1, matrix4x4 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
var a11 = new Matrix2x2(matrix1.row1.Point1,matrix1.row2.Point1);
var a12 = new Matrix2x2(matrix1.row1.Point2,matrix1.row2.Point2);
var a11 = new matrix2x2(matrix1.row1.Point1,matrix1.row2.Point1);
var a12 = new matrix2x2(matrix1.row1.Point2,matrix1.row2.Point2);
var a21 = matrix1.row3.Point1;
var a22 = matrix1.row3.Point2;
var b11 = new Matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
var b12 = new Matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
var b21 = new Matrix2x2(matrix2.row3.Point1, matrix2.row4.Point1);
var b22 = new Matrix2x2(matrix2.row3.Point2, matrix2.row4.Point2);
var b11 = new matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
var b12 = new matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
var b21 = new matrix2x2(matrix2.row3.Point1, matrix2.row4.Point1);
var b22 = new matrix2x2(matrix2.row3.Point2, matrix2.row4.Point2);
var c1 = a11.multiple(b11) + a12.multiple(b21);
var c2 = a11.multiple(b12) + a12.multiple(b22);
var c3 = a21.multiple(b11) + a22.multiple(b21);
var c4 = a21.multiple(b12) + a22.multiple(b22);
return new Matrix3x4(
new Vec4D(c1.row1,c2.row1),
new Vec4D(c1.row2,c2.row2),
new Vec4D(c3,c4)
return new matrix3x4(
new vec4d(c1.row1,c2.row1),
new vec4d(c1.row2,c2.row2),
new vec4d(c3,c4)
) ;
}
public static unsafe Matrix4x2 multiple(this Matrix4x2 matrix1, Matrix2x2 matrix2)
public static unsafe matrix4x2 multiple(this matrix4x2 matrix1, matrix2x2 matrix2)
{
float* p = &matrix1.row1.X;
var a11 = new Colum2D(*(p + 0), *(p + 2));
var a12 = new Colum2D(*(p + 1), *(p + 3));
var a21 = new Colum2D(*(p + 4), *(p + 6));
var a22 = new Colum2D(*(p + 5), *(p + 7));
var a11 = new colum2(*(p + 0), *(p + 2));
var a12 = new colum2(*(p + 1), *(p + 3));
var a21 = new colum2(*(p + 4), *(p + 6));
var a22 = new colum2(*(p + 5), *(p + 7));
var b11 = matrix2.row1.X;
var b12 = matrix2.row1.Y;
@@ -810,23 +810,23 @@ namespace StgSharp.Math
var u6 = u3 - m4;
var u7 = u3 + m5;
return new Matrix4x2(
new Vec2D(u1.X,u5.X),
new Vec2D(u1.Y,u5.Y),
new Vec2D(u6.X,u7.X),
new Vec2D(u6.Y,u7.Y)
return new matrix4x2(
new vec2d(u1.X,u5.X),
new vec2d(u1.Y,u5.Y),
new vec2d(u6.X,u7.X),
new vec2d(u6.Y,u7.Y)
);
}
public static unsafe Matrix4x3 multiple(this Matrix4x2 matrix1, Matrix2x3 matrix2)
public static unsafe matrix4x3 multiple(this matrix4x2 matrix1, matrix2x3 matrix2)
{
float* p = &matrix2.row1.X;
var a1 = new Matrix2x2(matrix1.row1, matrix1.row2);
var a2 = new Matrix2x2(matrix1.row3, matrix1.row4);
var a1 = new matrix2x2(matrix1.row1, matrix1.row2);
var a2 = new matrix2x2(matrix1.row3, matrix1.row4);
var b1 = new Matrix2x2(*(p + 0), *(p + 1), *(p + 3), *(p + 4));
var b2 = new Colum2D(*(p + 2), *(p + 5));
var b1 = new matrix2x2(*(p + 0), *(p + 1), *(p + 3), *(p + 4));
var b2 = new colum2(*(p + 2), *(p + 5));
var c11 = a1.multiple(b1);
var c12 = a1.multiple(b2);
@@ -836,7 +836,7 @@ namespace StgSharp.Math
float* pc1 = &c11.row1.X;
float* pc2 = &c21.row1.X;
return new Matrix4x3(
return new matrix4x3(
*(pc1 + 0), *(pc1 + 1),c12.X,
*(pc1 + 2), *(pc1 + 3),c12.Y,
*(pc2 + 0), *(pc2 + 1),c22.X,
@@ -850,20 +850,20 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix4x4 multiple(this Matrix4x2 matrix1, Matrix2x4 matrix2)
public static unsafe matrix4x4 multiple(this matrix4x2 matrix1, matrix2x4 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
Colum2D a11 = new Colum2D(*(p1 + 0), *(p1 + 2));
Colum2D a12 = new Colum2D(*(p1 + 1), *(p1 + 3));
Colum2D a21 = new Colum2D(*(p1 + 4), *(p1 + 6));
Colum2D a22 = new Colum2D(*(p1 + 5), *(p1 + 7));
colum2 a11 = new colum2(*(p1 + 0), *(p1 + 2));
colum2 a12 = new colum2(*(p1 + 1), *(p1 + 3));
colum2 a21 = new colum2(*(p1 + 4), *(p1 + 6));
colum2 a22 = new colum2(*(p1 + 5), *(p1 + 7));
Vec2D b11 = new Vec2D(*(p2 + 0), *(p2 + 1));
Vec2D b12 = new Vec2D(*(p2 + 2), *(p2 + 3));
Vec2D b21 = new Vec2D(*(p2 + 4), *(p2 + 5));
Vec2D b22 = new Vec2D(*(p2 + 6), *(p2 + 7));
vec2d b11 = new vec2d(*(p2 + 0), *(p2 + 1));
vec2d b12 = new vec2d(*(p2 + 2), *(p2 + 3));
vec2d b21 = new vec2d(*(p2 + 4), *(p2 + 5));
vec2d b22 = new vec2d(*(p2 + 6), *(p2 + 7));
var s1 = a21 + a22;
var s2 = s1 - a11;
@@ -891,47 +891,47 @@ namespace StgSharp.Math
var u6 = u3 - m4;
var u7 = u3 + m5;
return new Matrix4x4(
new Vec4D(u1.row1.X, u1.row1.Y, u5.row1.X, u5.row1.Y),
new Vec4D(u1.row2.X, u1.row2.Y, u5.row2.X, u5.row2.Y),
new Vec4D(u6.row1.X, u6.row1.Y, u7.row1.X, u7.row1.Y),
new Vec4D(u6.row2.X, u6.row2.Y, u7.row2.X, u7.row2.Y)
return new matrix4x4(
new vec4d(u1.row1.X, u1.row1.Y, u5.row1.X, u5.row1.Y),
new vec4d(u1.row2.X, u1.row2.Y, u5.row2.X, u5.row2.Y),
new vec4d(u6.row1.X, u6.row1.Y, u7.row1.X, u7.row1.Y),
new vec4d(u6.row2.X, u6.row2.Y, u7.row2.X, u7.row2.Y)
);
}
public static unsafe Matrix4x2 multiple(this Matrix4x3 matrix1, Matrix3x2 matrix2)
public static unsafe matrix4x2 multiple(this matrix4x3 matrix1, matrix3x2 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
var a11 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new Colum2D(*(p1 + 2), *(p1 + 5));
var a21 = new Matrix2x2(*(p1 + 6), *(p1 + 7), *(p1 + 9), *(p1 + 10));
var a22 = new Colum2D(*(p1 + 8), *(p1 + 11));
var a11 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new colum2(*(p1 + 2), *(p1 + 5));
var a21 = new matrix2x2(*(p1 + 6), *(p1 + 7), *(p1 + 9), *(p1 + 10));
var a22 = new colum2(*(p1 + 8), *(p1 + 11));
var b1 = new Matrix2x2(*(p2 + 0), *(p2 + 0), *(p2 + 0), *(p2 + 0));
var b1 = new matrix2x2(*(p2 + 0), *(p2 + 0), *(p2 + 0), *(p2 + 0));
var b2 = matrix2.row3;
var c1 = a11.multiple(b1) + a12.multiple(b2);
var c2 = a21.multiple(b1) + a22.multiple(b2);
return new Matrix4x2(c1.row1,c1.row2,c2.row1,c2.row2);
return new matrix4x2(c1.row1,c1.row2,c2.row1,c2.row2);
}
public static unsafe Matrix4x3 multiple(this Matrix4x3 matrix1, Matrix3x3 matrix2)
public static unsafe matrix4x3 multiple(this matrix4x3 matrix1, matrix3x3 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
var a11 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new Colum2D(*(p1 + 2), *(p1 + 5));
var a21 = new Matrix2x2(*(p1 + 6), *(p1 + 7), *(p1 + 9), *(p1 + 10));
var a22 = new Colum2D(*(p1 + 8), *(p1 + 11));
var a11 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new colum2(*(p1 + 2), *(p1 + 5));
var a21 = new matrix2x2(*(p1 + 6), *(p1 + 7), *(p1 + 9), *(p1 + 10));
var a22 = new colum2(*(p1 + 8), *(p1 + 11));
var b11 = new Matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4));
var b12 = new Colum2D(*(p2 + 2), *(p2 + 5));
var b21 = new Vec2D(*(p2 + 9), *(p2 + 10));
var b11 = new matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 3), *(p2 + 4));
var b12 = new colum2(*(p2 + 2), *(p2 + 5));
var b21 = new vec2d(*(p2 + 9), *(p2 + 10));
var b22 = matrix2.row3.Z;
var c11 = a11.multiple(b11) + a12.multiple(b21);
@@ -942,7 +942,7 @@ namespace StgSharp.Math
float* p3 = &c11.row1.X;
float* p4 = &c21.row1.X;
return new Matrix4x3(
return new matrix4x3(
*(p3 + 0), *(p3 + 1),c12.X,
*(p3 + 2), *(p3 + 3),c12.Y,
*(p4 + 0), *(p4 + 1),c22.X,
@@ -950,18 +950,18 @@ namespace StgSharp.Math
);
}
public static unsafe Matrix4x4 multiple(this Matrix4x3 matrix1, Matrix3x4 matrix2)
public static unsafe matrix4x4 multiple(this matrix4x3 matrix1, matrix3x4 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
var a11 = new Matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new Colum2D(*(p1 + 2), *(p1 + 5));
var a21 = new Matrix2x2(*(p1 + 6), *(p1 + 7), *(p1 + 9), *(p1 + 10));
var a22 = new Colum2D(*(p1 + 8), *(p1 + 11));
var a11 = new matrix2x2(*(p1 + 0), *(p1 + 1), *(p1 + 3), *(p1 + 4));
var a12 = new colum2(*(p1 + 2), *(p1 + 5));
var a21 = new matrix2x2(*(p1 + 6), *(p1 + 7), *(p1 + 9), *(p1 + 10));
var a22 = new colum2(*(p1 + 8), *(p1 + 11));
var b11 = new Matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 4), *(p2 + 5));
var b12 = new Matrix2x2(*(p2 + 2), *(p2 + 3), *(p2 + 6), *(p2 + 7));
var b11 = new matrix2x2 (*(p2 + 0), *(p2 + 1), *(p2 + 4), *(p2 + 5));
var b12 = new matrix2x2(*(p2 + 2), *(p2 + 3), *(p2 + 6), *(p2 + 7));
var b21 = matrix2.row3.Point1;
var b22 = matrix2.row3.Point2;
@@ -970,11 +970,11 @@ namespace StgSharp.Math
var c21 = a21.multiple(b11) + a22.multiple(b21);
var c22 = a21.multiple(b12) + a22.multiple(b22);
return new Matrix4x4(
new Vec4D(c11.row1, c12.row1),
new Vec4D(c11.row2, c12.row2),
new Vec4D(c21.row1, c22.row1),
new Vec4D(c21.row2, c22.row2)
return new matrix4x4(
new vec4d(c11.row1, c12.row1),
new vec4d(c11.row2, c12.row2),
new vec4d(c21.row1, c22.row1),
new vec4d(c21.row2, c22.row2)
);
}
@@ -984,20 +984,20 @@ namespace StgSharp.Math
/// <param name="matrix1"></param>
/// <param name="matrix2"></param>
/// <returns></returns>
public static unsafe Matrix4x4 multiple(this Matrix4x4 matrix1, Matrix4x4 matrix2)
public static unsafe matrix4x4 multiple(this matrix4x4 matrix1, matrix4x4 matrix2)
{
float* p1 = &matrix1.row1.X;
float* p2 = &matrix2.row1.X;
Matrix2x2 a11 = new Matrix2x2(*p1, *(p1 + 1), *(p1 + 4), *(p1 + 5));
Matrix2x2 a12 = new Matrix2x2(*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7));
Matrix2x2 a21 = new Matrix2x2(*(p1 + 8), *(p1 + 9), *(p1 + 12), *(p1 + 13));
Matrix2x2 a22 = new Matrix2x2(*(p1 + 10), *(p1 + 11), *(p1 + 14), *(p1 + 15));
matrix2x2 a11 = new matrix2x2(*p1, *(p1 + 1), *(p1 + 4), *(p1 + 5));
matrix2x2 a12 = new matrix2x2(*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7));
matrix2x2 a21 = new matrix2x2(*(p1 + 8), *(p1 + 9), *(p1 + 12), *(p1 + 13));
matrix2x2 a22 = new matrix2x2(*(p1 + 10), *(p1 + 11), *(p1 + 14), *(p1 + 15));
Matrix2x2 b11 = new Matrix2x2(*p1, *(p1 + 1), *(p1 + 4), *(p1 + 5));
Matrix2x2 b12 = new Matrix2x2(*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7));
Matrix2x2 b21 = new Matrix2x2(*(p1 + 8), *(p1 + 9), *(p1 + 12), *(p1 + 13));
Matrix2x2 b22 = new Matrix2x2(*(p1 + 10), *(p1 + 11), *(p1 + 14), *(p1 + 15));
matrix2x2 b11 = new matrix2x2(*p1, *(p1 + 1), *(p1 + 4), *(p1 + 5));
matrix2x2 b12 = new matrix2x2(*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7));
matrix2x2 b21 = new matrix2x2(*(p1 + 8), *(p1 + 9), *(p1 + 12), *(p1 + 13));
matrix2x2 b22 = new matrix2x2(*(p1 + 10), *(p1 + 11), *(p1 + 14), *(p1 + 15));
var s1 = a21 + a22;
var s2 = s1 - a11;
@@ -1025,11 +1025,11 @@ namespace StgSharp.Math
var u6 = u3 - m4;
var u7 = u3 + m5;
return new Matrix4x4(
new Vec4D(u1.row1.X, u1.row1.Y, u5.row1.X, u5.row1.Y),
new Vec4D(u1.row2.X, u1.row2.Y, u5.row2.X, u5.row2.Y),
new Vec4D(u6.row1.X, u6.row1.Y, u7.row1.X, u7.row1.Y),
new Vec4D(u6.row2.X, u6.row2.Y, u7.row2.X, u7.row2.Y)
return new matrix4x4(
new vec4d(u1.row1.X, u1.row1.Y, u5.row1.X, u5.row1.Y),
new vec4d(u1.row2.X, u1.row2.Y, u5.row2.X, u5.row2.Y),
new vec4d(u6.row1.X, u6.row1.Y, u7.row1.X, u7.row1.Y),
new vec4d(u6.row2.X, u6.row2.Y, u7.row2.X, u7.row2.Y)
);
}
@@ -7,36 +7,36 @@ namespace StgSharp.Math
{
public static unsafe partial class Vector
{
public static Vec3D To3D(this Vec2D vec)
public static vec3d To3D(this vec2d vec)
{
return new Vec3D(vec.X, vec.Y, 0.0f);
return new vec3d(vec.X, vec.Y, 0.0f);
}
public static Vec4D To4D(this Vec2D Vec)
public static vec4d To4D(this vec2d Vec)
{
return new Vec4D(Vec.X, Vec.Y, 0, 0);
return new vec4d(Vec.X, Vec.Y, 0, 0);
}
public static Vec4D To4D(this Vec3D vec)
public static vec4d To4D(this vec3d vec)
{
return new Vec4D(vec.X, vec.Y, vec.Z, 0);
return new vec4d(vec.X, vec.Y, vec.Z, 0);
}
public static Vec2D To2D(Vec3D vec, CordinatePlain plain)
public static vec2d To2D(vec3d vec, CordinatePlain plain)
{
switch (plain)
{
case CordinatePlain.XY:
return new Vec2D(vec.X, vec.Y);
return new vec2d(vec.X, vec.Y);
break;
case CordinatePlain.YZ:
return new Vec2D(vec.Y, vec.Z);
return new vec2d(vec.Y, vec.Z);
break;
case CordinatePlain.XZ:
return new Vec2D(vec.X, vec.Z);
return new vec2d(vec.X, vec.Z);
break;
default:
return default(Vec2D);
return default(vec2d);
break;
}
}
@@ -7,14 +7,14 @@ namespace StgSharp.Math
public static unsafe partial class Vector
{
public static float Cross(Vec2D vec1, Vec2D vec2)
public static float Cross(vec2d vec1, vec2d vec2)
{
return vec1.X * vec2.Y - vec1.Y * vec2.X;
}
public static Vec3D Cross(Vec3D vec1, Vec3D vec2)
public static vec3d Cross(vec3d vec1, vec3d vec2)
{
return new Vec3D(
return new vec3d(
vec1.Y * vec2.Z - vec1.Z * vec2.Y,
vec1.X * vec2.Z - vec1.Z * vec2.X,
vec1.X * vec2.Y - vec1.Y * vec2.X
@@ -6,14 +6,14 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Colum2D:IEquatable<Colum2D>
public struct colum2:IEquatable<colum2>
{
[FieldOffset(0)]
public float X;
[FieldOffset(4)]
public float Y;
public Colum2D(float x,float y)
public colum2(float x,float y)
{
X= x;
Y= y;
@@ -25,17 +25,17 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Colum2D))
else if (obj.GetType() != typeof(colum2))
{
return false;
}
else
{
return this.Equals((Colum2D)obj);
return this.Equals((colum2)obj);
}
}
bool IEquatable<Colum2D>.Equals(Colum2D other)
bool IEquatable<colum2>.Equals(colum2 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -57,30 +57,30 @@ namespace StgSharp.Math
return $"{X}\n{Y}";
}
public static Colum2D operator +(Colum2D c1,Colum2D c2)
public static colum2 operator +(colum2 c1,colum2 c2)
{
return new Colum2D(
return new colum2(
c1.X + c2.X,
c1.Y + c2.Y
);
}
public static Colum2D operator -(Colum2D c1, Colum2D c2)
public static colum2 operator -(colum2 c1, colum2 c2)
{
return new Colum2D(
return new colum2(
c1.X - c2.X,
c1.Y - c2.Y
);
}
public static Colum2D operator *(Colum2D colum, float x)
public static colum2 operator *(colum2 colum, float x)
{
return new Colum2D(colum.X * x,colum.Y * x);
return new colum2(colum.X * x,colum.Y * x);
}
public static Colum2D operator /(Colum2D colum, float x)
public static colum2 operator /(colum2 colum, float x)
{
return new Colum2D(colum.X / x, colum.Y / x);
return new colum2(colum.X / x, colum.Y / x);
}
}
}
@@ -6,7 +6,7 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Colum3D : IEquatable<Colum3D>
public struct colum3 : IEquatable<colum3>
{
[FieldOffset(0)]
public float X;
@@ -15,14 +15,14 @@ namespace StgSharp.Math
[FieldOffset(8)]
public float Z;
public Colum3D(float x, float y, float z)
public colum3(float x, float y, float z)
{
X = x;
Y = y;
Z = z;
}
bool IEquatable<Colum3D>.Equals(Colum3D other)
bool IEquatable<colum3>.Equals(colum3 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -42,13 +42,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Colum3D))
else if (obj.GetType() != typeof(colum3))
{
return false;
}
else
{
return this.Equals((Colum3D)obj);
return this.Equals((colum3)obj);
}
}
@@ -62,39 +62,39 @@ namespace StgSharp.Math
return $"{X}\t{Y}\t{Z}";
}
public static bool operator ==(Colum3D vec1, Colum3D vec2)
public static bool operator ==(colum3 vec1, colum3 vec2)
{
return vec1.X == vec2.X
&& vec1.Y == vec2.Y
&& vec1.Z == vec2.Z;
}
public static bool operator !=(Colum3D vec1, Colum3D vec2)
public static bool operator !=(colum3 vec1, colum3 vec2)
{
return !(vec1.X == vec2.X
&& vec1.Y == vec2.Y
&& vec1.Z == vec2.Z);
}
public static Colum3D operator +(Colum3D vec1, Colum3D vec2)
public static colum3 operator +(colum3 vec1, colum3 vec2)
{
return new Colum3D(
return new colum3(
vec1.X + vec2.X,
vec1.Y + vec2.Y,
vec1.Z + vec2.Z
);
}
public static Colum3D operator -(Colum3D vec1, Colum3D vec2)
public static colum3 operator -(colum3 vec1, colum3 vec2)
{
return new Colum3D(
return new colum3(
vec1.X - vec2.X,
vec1.Y - vec2.Y,
vec1.Z - vec2.Z
);
}
public static float operator *(Colum3D vec1, Colum3D vec2)
public static float operator *(colum3 vec1, colum3 vec2)
{
return
vec1.X * vec2.X
@@ -102,18 +102,18 @@ namespace StgSharp.Math
+ vec1.Z + vec2.Z;
}
public static Colum3D operator *(Colum3D vec, float x)
public static colum3 operator *(colum3 vec, float x)
{
return new Colum3D(
return new colum3(
vec.X * x,
vec.Y * x,
vec.Z * x
);
}
public static Colum3D operator /(Colum3D vec, float x)
public static colum3 operator /(colum3 vec, float x)
{
return new Colum3D(
return new colum3(
vec.X / x,
vec.Y / x,
vec.Z / x
@@ -7,7 +7,7 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Colum4D:IEquatable<Colum4D>
public struct colum4:IEquatable<colum4>
{
[FieldOffset(0)]
public float X;
@@ -18,7 +18,7 @@ namespace StgSharp.Math
[FieldOffset(12)]
public float W;
public Colum4D(float x, float y, float z, float w)
public colum4(float x, float y, float z, float w)
{
X = x;
Y = y;
@@ -26,7 +26,7 @@ namespace StgSharp.Math
W = w;
}
public bool Equals(Colum4D other)
public bool Equals(colum4 other)
{
throw new NotImplementedException();
}
@@ -7,32 +7,32 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix2x2:IEquatable<Matrix2x2>
public struct matrix2x2:IEquatable<matrix2x2>
{
[FieldOffset(0)]
public Vec2D row1;
public vec2d row1;
[FieldOffset(8)]
public Vec2D row2;
public vec2d row2;
public Matrix2x2(Vec2D c0, Vec2D c1)
public matrix2x2(vec2d c0, vec2d c1)
{
row1 = c0;
row2 = c1;
}
public Matrix2x2(
public matrix2x2(
float a11,
float a12,
float a21,
float a22
)
{
row1 = new Vec2D(a11, a12);
row2 = new Vec2D(a21, a22);
row1 = new vec2d(a11, a12);
row2 = new vec2d(a21, a22);
}
bool IEquatable<Matrix2x2>.Equals(Matrix2x2 other)
bool IEquatable<matrix2x2>.Equals(matrix2x2 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -52,13 +52,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Matrix2x2))
else if (obj.GetType() != typeof(matrix2x2))
{
return false;
}
else
{
return this.Equals((Vec3D)obj);
return this.Equals((vec3d)obj);
}
}
@@ -72,17 +72,17 @@ namespace StgSharp.Math
return $"{row1}\n{row2}";
}
public static Matrix2x2 operator +(Matrix2x2 matrix1 , Matrix2x2 matrix2)
public static matrix2x2 operator +(matrix2x2 matrix1 , matrix2x2 matrix2)
{
return new Matrix2x2(
return new matrix2x2(
matrix1.row1 + matrix2.row1,
matrix1.row2 + matrix2.row2
);
}
public static Matrix2x2 operator -(Matrix2x2 matrix1, Matrix2x2 matrix2)
public static matrix2x2 operator -(matrix2x2 matrix1, matrix2x2 matrix2)
{
return new Matrix2x2(
return new matrix2x2(
matrix1.row1 - matrix2.row1,
matrix1.row2 - matrix2.row2
);
@@ -7,26 +7,26 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix2x3:IEquatable<Matrix2x3>
public struct matrix2x3:IEquatable<matrix2x3>
{
[FieldOffset(0)]
public Vec3D row1;
public vec3d row1;
[FieldOffset(12)]
public Vec3D row2;
public vec3d row2;
public Matrix2x3(Vec3D r1, Vec3D r2)
public matrix2x3(vec3d r1, vec3d r2)
{
row1 = r1;
row2 = r2;
}
public Matrix2x3(
public matrix2x3(
float r11, float r12, float r13,
float r21, float r22, float r23
)
{
row1 = new Vec3D(r11, r12, r13);
row2 = new Vec3D(r21, r22, r23);
row1 = new vec3d(r11, r12, r13);
row2 = new vec3d(r21, r22, r23);
}
public override bool Equals(object obj)
@@ -35,13 +35,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Matrix2x3))
else if (obj.GetType() != typeof(matrix2x3))
{
return false;
}
else
{
return this.Equals((Vec3D)obj);
return this.Equals((vec3d)obj);
}
}
@@ -55,7 +55,7 @@ namespace StgSharp.Math
return $"{row1}\n{row2}";
}
bool IEquatable<Matrix2x3>.Equals(Matrix2x3 other)
bool IEquatable<matrix2x3>.Equals(matrix2x3 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -69,33 +69,33 @@ namespace StgSharp.Math
}
}
public static Matrix2x3 operator +(Matrix2x3 matrix1, Matrix2x3 matrix2)
public static matrix2x3 operator +(matrix2x3 matrix1, matrix2x3 matrix2)
{
return new Matrix2x3(
return new matrix2x3(
matrix1.row1 + matrix2.row1,
matrix1.row2 + matrix2.row2
);
}
public static Matrix2x3 operator -(Matrix2x3 matrix1, Matrix2x3 matrix2)
public static matrix2x3 operator -(matrix2x3 matrix1, matrix2x3 matrix2)
{
return new Matrix2x3(
return new matrix2x3(
matrix1.row1 - matrix2.row1,
matrix1.row2 - matrix2.row2
);
}
public static Matrix2x3 operator *(Matrix2x3 array, float x)
public static matrix2x3 operator *(matrix2x3 array, float x)
{
return new Matrix2x3(
return new matrix2x3(
array.row1 * x,
array.row2 * x
) ;
}
public static Matrix2x3 operator /(Matrix2x3 array, float x)
public static matrix2x3 operator /(matrix2x3 array, float x)
{
return new Matrix2x3(
return new matrix2x3(
array.row1 / x,
array.row2 / x
);
@@ -7,29 +7,29 @@ namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix2x4 : IEquatable<Matrix2x4>
public struct matrix2x4 : IEquatable<matrix2x4>
{
[FieldOffset(0)]
public Vec4D row1;
public vec4d row1;
[FieldOffset(16)]
public Vec4D row2;
public vec4d row2;
public Matrix2x4(Vec4D r1,Vec4D r2)
public matrix2x4( vec4d r1, vec4d r2)
{
row1 = r1;
row2 = r2;
}
public Matrix2x4(
public matrix2x4(
float a11, float a12, float a13, float a14,
float a21, float a22, float a23, float a24
)
{
row1 = new Vec4D(a11,a12,a13,a14);
row2 = new Vec4D(a21,a22,a23,a24);
row1 = new vec4d(a11,a12,a13,a14);
row2 = new vec4d(a21,a22,a23,a24);
}
public bool Equals(Matrix2x4 other)
public bool Equals(matrix2x4 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -48,13 +48,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Matrix2x4))
else if (obj.GetType() != typeof(matrix2x4))
{
return false;
}
else
{
return this.Equals((Matrix2x4)obj);
return this.Equals((matrix2x4)obj);
}
}
@@ -68,33 +68,33 @@ namespace StgSharp.Math
return $"{this.row1}\n{this.row2}";
}
public static Matrix2x4 operator +(Matrix2x4 matrix1 ,Matrix2x4 matrix2)
public static matrix2x4 operator +(matrix2x4 matrix1 ,matrix2x4 matrix2)
{
return new Matrix2x4(
return new matrix2x4(
matrix1.row1 + matrix2.row1,
matrix1.row2 + matrix2.row2
) ;
}
public static Matrix2x4 operator -(Matrix2x4 matrix1, Matrix2x4 matrix2)
public static matrix2x4 operator -(matrix2x4 matrix1, matrix2x4 matrix2)
{
return new Matrix2x4(
return new matrix2x4(
matrix1.row1 - matrix2.row1,
matrix1.row2 - matrix2.row2
);
}
public static Matrix2x4 operator *(Matrix2x4 array, float x)
public static matrix2x4 operator *(matrix2x4 array, float x)
{
return new Matrix2x4(
return new matrix2x4(
array.row1 * x,
array.row2 * x
);
}
public static Matrix2x4 operator /(Matrix2x4 array, float x)
public static matrix2x4 operator /(matrix2x4 array, float x)
{
return new Matrix2x4(
return new matrix2x4(
array.row1 / x,
array.row2 / x
);
@@ -6,34 +6,34 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix3x2:IEquatable<Matrix3x2>
public struct matrix3x2:IEquatable<matrix3x2>
{
[FieldOffset(0)]
public Vec2D row1;
public vec2d row1;
[FieldOffset(8)]
public Vec2D row2;
public vec2d row2;
[FieldOffset(16)]
public Vec2D row3;
public vec2d row3;
public Matrix3x2(Vec2D r1,Vec2D r2,Vec2D r3)
public matrix3x2(vec2d r1,vec2d r2,vec2d r3)
{
row1= r1;
row2= r2;
row3= r3;
}
public Matrix3x2(
public matrix3x2(
float a11, float a12,
float a21, float a22,
float a31, float a32
)
{
row1 = new Vec2D(a11, a12);
row2 = new Vec2D(a21, a22);
row3 = new Vec2D(a31, a32);
row1 = new vec2d(a11, a12);
row2 = new vec2d(a21, a22);
row3 = new vec2d(a31, a32);
}
bool IEquatable<Matrix3x2>.Equals(Matrix3x2 other)
bool IEquatable<matrix3x2>.Equals(matrix3x2 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -55,13 +55,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Matrix3x2))
else if (obj.GetType() != typeof(matrix3x2))
{
return false;
}
else
{
return this.Equals((Matrix3x2)obj);
return this.Equals((matrix3x2)obj);
}
}
@@ -75,18 +75,18 @@ namespace StgSharp.Math
return $"{row1}\n{row2}\n{row3}";
}
public static Matrix3x2 operator +(Matrix3x2 matrix1, Matrix3x2 matrix2)
public static matrix3x2 operator +(matrix3x2 matrix1, matrix3x2 matrix2)
{
return new Matrix3x2(
return new matrix3x2(
matrix1.row1 + matrix2.row1,
matrix1.row2 + matrix2.row2,
matrix1.row3 + matrix2.row3
);
}
public static Matrix3x2 operator -(Matrix3x2 matrix1, Matrix3x2 matrix2)
public static matrix3x2 operator -(matrix3x2 matrix1, matrix3x2 matrix2)
{
return new Matrix3x2(
return new matrix3x2(
matrix1.row1 - matrix2.row1,
matrix1.row2 - matrix2.row2,
matrix1.row3 - matrix2.row3
@@ -7,31 +7,31 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix3x3:IEquatable<Matrix3x3>
public struct matrix3x3:IEquatable<matrix3x3>
{
[FieldOffset(0)]
public Vec3D row1;
public vec3d row1;
[FieldOffset(12)]
public Vec3D row2;
public vec3d row2;
[FieldOffset(24)]
public Vec3D row3;
public vec3d row3;
public Matrix3x3(Vec3D r0,Vec3D r1,Vec3D r2)
public matrix3x3(vec3d r0,vec3d r1,vec3d r2)
{
row1 = r0;
row2 = r1;
row3 = r2;
}
public Matrix3x3(
public matrix3x3(
float a11,float a12,float a13,
float a21,float a22,float a23,
float a31,float a32,float a33
)
{
row1 = new Vec3D(a11, a12, a13);
row2 = new Vec3D(a21, a22, a23);
row3 = new Vec3D(a31, a32, a33);
row1 = new vec3d(a11, a12, a13);
row2 = new vec3d(a21, a22, a23);
row3 = new vec3d(a31, a32, a33);
}
public override int GetHashCode()
@@ -39,7 +39,7 @@ namespace StgSharp.Math
return HashCode.Combine(row1,row2,row3);
}
bool IEquatable<Matrix3x3>.Equals(Matrix3x3 other)
bool IEquatable<matrix3x3>.Equals(matrix3x3 other)
{
if (this.GetHashCode()!=other.GetHashCode())
{
@@ -60,13 +60,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Matrix3x3))
else if (obj.GetType() != typeof(matrix3x3))
{
return false;
}
else
{
return this.Equals((Matrix3x3)obj);
return this.Equals((matrix3x3)obj);
}
}
@@ -77,19 +77,19 @@ namespace StgSharp.Math
public static bool operator ==(Matrix3x3 matrix1, Matrix3x3 matrix2)
public static bool operator ==(matrix3x3 matrix1, matrix3x3 matrix2)
{
return matrix1.Equals(matrix2);
}
public static bool operator !=(Matrix3x3 matrix1, Matrix3x3 matrix2)
public static bool operator !=(matrix3x3 matrix1, matrix3x3 matrix2)
{
return !matrix1.Equals(matrix2);
}
public static Matrix3x3 operator +(Matrix3x3 matrix1, Matrix3x3 matrix2)
public static matrix3x3 operator +(matrix3x3 matrix1, matrix3x3 matrix2)
{
return new Matrix3x3(
return new matrix3x3(
matrix1.row1.X + matrix2.row1.X,
matrix1.row1.Y + matrix2.row1.Y,
matrix1.row1.Z + matrix2.row1.Z,
@@ -104,9 +104,9 @@ namespace StgSharp.Math
);
}
public static Matrix3x3 operator -(Matrix3x3 matrix1, Matrix3x3 matrix2)
public static matrix3x3 operator -(matrix3x3 matrix1, matrix3x3 matrix2)
{
return new Matrix3x3(
return new matrix3x3(
matrix1.row1.X - matrix2.row1.X,
matrix1.row1.Y - matrix2.row1.Y,
matrix1.row1.Z - matrix2.row1.Z,
@@ -123,18 +123,18 @@ namespace StgSharp.Math
public static Matrix3x3 operator *(Matrix3x3 array, float x)
public static matrix3x3 operator *(matrix3x3 array, float x)
{
return new Matrix3x3(
return new matrix3x3(
array.row1 * x,
array.row2 * x,
array.row3 * x
);
}
public static Matrix3x3 operator /(Matrix3x3 array, float x)
public static matrix3x3 operator /(matrix3x3 array, float x)
{
return new Matrix3x3(
return new matrix3x3(
array.row1/x,
array.row2/x,
array.row3/x
@@ -8,17 +8,17 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix3x4:IEquatable<Matrix3x4>
public struct matrix3x4:IEquatable<matrix3x4>
{
[FieldOffset(0)]
public Vec4D row1;
public vec4d row1;
[FieldOffset(16)]
public Vec4D row2;
public vec4d row2;
[FieldOffset(32)]
public Vec4D row3;
public vec4d row3;
public Matrix3x4(
Vec4D r1, Vec4D r2, Vec4D r3
public matrix3x4(
vec4d r1,vec4d r2,vec4d r3
)
{
this.row1 = r1;
@@ -26,15 +26,15 @@ namespace StgSharp.Math
this.row3 = r3;
}
public Matrix3x4(
public matrix3x4(
float a11, float a12, float a13, float a14,
float a21, float a22, float a23, float a24,
float a31, float a32, float a33, float a34
)
{
row1 = new Vec4D(a11,a12,a13,a14);
row2 = new Vec4D(a21,a22,a23,a24);
row3 = new Vec4D(a31,a32,a33,a34);
row1 = new vec4d(a11,a12,a13,a14);
row2 = new vec4d(a21,a22,a23,a24);
row3 = new vec4d(a31,a32,a33,a34);
}
public override bool Equals(object obj)
@@ -43,17 +43,17 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Matrix3x4))
else if (obj.GetType() != typeof(matrix3x4))
{
return false;
}
else
{
return this.Equals((Matrix3x4)obj);
return this.Equals((matrix3x4)obj);
}
}
bool IEquatable<Matrix3x4>.Equals(Matrix3x4 other)
bool IEquatable<matrix3x4>.Equals(matrix3x4 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -6,18 +6,18 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix4x2:IEquatable<Matrix4x2>
public struct matrix4x2:IEquatable<matrix4x2>
{
[FieldOffset(0)]
public Vec2D row1;
public vec2d row1;
[FieldOffset(8)]
public Vec2D row2;
public vec2d row2;
[FieldOffset(16)]
public Vec2D row3;
public vec2d row3;
[FieldOffset(24)]
public Vec2D row4;
public vec2d row4;
public Matrix4x2(Vec2D r1, Vec2D r2, Vec2D r3, Vec2D r4)
public matrix4x2(vec2d r1, vec2d r2, vec2d r3, vec2d r4)
{
row1 = r1;
row2 = r2;
@@ -25,17 +25,17 @@ namespace StgSharp.Math
row4 = r4;
}
public Matrix4x2(
public matrix4x2(
float a11, float a12,
float a21, float a22,
float a31, float a32,
float a41, float a42
)
{
row1 = new Vec2D(a11, a12);
row2 = new Vec2D(a21, a22);
row3 = new Vec2D(a31, a32);
row4 = new Vec2D(a41, a42);
row1 = new vec2d(a11, a12);
row2 = new vec2d(a21, a22);
row3 = new vec2d(a31, a32);
row4 = new vec2d(a41, a42);
}
public override bool Equals(object obj)
@@ -44,13 +44,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() == typeof(Matrix4x2))
else if (obj.GetType() == typeof(matrix4x2))
{
return false;
}
else
{
return this.Equals((Matrix4x2)obj);
return this.Equals((matrix4x2)obj);
}
}
@@ -64,7 +64,7 @@ namespace StgSharp.Math
return $"{row1}\n{row2}\n{row3}\n{row4}";
}
bool IEquatable<Matrix4x2>.Equals(Matrix4x2 other)
bool IEquatable<matrix4x2>.Equals(matrix4x2 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -7,28 +7,28 @@ namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix4x3:IEquatable<Matrix4x3>
public struct matrix4x3:IEquatable<matrix4x3>
{
[FieldOffset(0)]
public Vec3D row1;
public vec3d row1;
[FieldOffset(12)]
public Vec3D row2;
public vec3d row2;
[FieldOffset(24)]
public Vec3D row3;
public vec3d row3;
[FieldOffset(36)]
public Vec3D row4;
public vec3d row4;
public Matrix4x3(
public matrix4x3(
float a11, float a12, float a13,
float a21, float a22, float a23,
float a31, float a32, float a33,
float a41, float a42, float a43
)
{
row1 = new Vec3D(a11, a12, a13);
row2 = new Vec3D(a21, a22, a23);
row3 = new Vec3D(a31, a32, a33);
row4 = new Vec3D(a41, a42, a43);
row1 = new vec3d(a11, a12, a13);
row2 = new vec3d(a21, a22, a23);
row3 = new vec3d(a31, a32, a33);
row4 = new vec3d(a41, a42, a43);
}
public override bool Equals(object obj)
@@ -37,17 +37,17 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Matrix4x3))
else if (obj.GetType() != typeof(matrix4x3))
{
return false;
}
else
{
return this.Equals((Matrix4x3)obj);
return this.Equals((matrix4x3)obj);
}
}
bool IEquatable<Matrix4x3>.Equals(Matrix4x3 other)
bool IEquatable<matrix4x3>.Equals(matrix4x3 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -6,18 +6,18 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Matrix4x4:IEquatable<Matrix4x4>
public struct matrix4x4:IEquatable<matrix4x4>
{
[FieldOffset(0)]
public Vec4D row1;
public vec4d row1;
[FieldOffset(16)]
public Vec4D row2;
public vec4d row2;
[FieldOffset(32)]
public Vec4D row3;
public vec4d row3;
[FieldOffset(48)]
public Vec4D row4;
public vec4d row4;
public Matrix4x4(Vec4D r1, Vec4D r2, Vec4D r3, Vec4D r4)
public matrix4x4( vec4d r1,vec4d r2,vec4d r3,vec4d r4)
{
row1 = r1;
row2 = r2;
@@ -25,17 +25,17 @@ namespace StgSharp.Math
row4 = r4;
}
public Matrix4x4(
public matrix4x4(
float a11, float a12, float a13, float a14,
float a21, float a22, float a23, float a24,
float a31, float a32, float a33, float a34,
float a41, float a42, float a43, float a44
)
{
row1 = new Vec4D(a11, a12, a13, a14);
row2 = new Vec4D(a21, a22, a23, a24);
row3 = new Vec4D(a31, a32, a33, a34);
row4 = new Vec4D(a41, a42, a43, a44);
row1 = new vec4d(a11, a12, a13, a14);
row2 = new vec4d(a21, a22, a23, a24);
row3 = new vec4d(a31, a32, a33, a34);
row4 = new vec4d(a41, a42, a43, a44);
}
public override bool Equals(object obj)
@@ -43,7 +43,7 @@ namespace StgSharp.Math
return base.Equals(obj);
}
bool IEquatable<Matrix4x4>.Equals(Matrix4x4 other)
bool IEquatable<matrix4x4>.Equals(matrix4x4 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -68,9 +68,9 @@ namespace StgSharp.Math
return $"{this.row1}\n{this.row2}\n{this.row3}\n{this.row4}";
}
public static Matrix4x4 operator +(Matrix4x4 matrix1, Matrix4x4 matrix2)
public static matrix4x4 operator +(matrix4x4 matrix1, matrix4x4 matrix2)
{
return new Matrix4x4(
return new matrix4x4(
matrix1.row1 + matrix2.row1,
matrix1.row2 + matrix2.row2,
matrix1.row3 + matrix2.row3,
@@ -78,9 +78,9 @@ namespace StgSharp.Math
);
}
public static Matrix4x4 operator -(Matrix4x4 matrix1, Matrix4x4 matrix2)
public static matrix4x4 operator -(matrix4x4 matrix1, matrix4x4 matrix2)
{
return new Matrix4x4(
return new matrix4x4(
matrix1.row1 - matrix2.row1,
matrix1.row2 - matrix2.row2,
matrix1.row3 - matrix2.row3,
@@ -88,9 +88,9 @@ namespace StgSharp.Math
);
}
public static Matrix4x4 operator *(Matrix4x4 array, float x)
public static matrix4x4 operator *(matrix4x4 array, float x)
{
return new Matrix4x4(
return new matrix4x4(
array.row1 * x,
array.row2 * x,
array.row3 * x,
@@ -9,20 +9,20 @@ namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Vec2D:IEquatable<Vec2D>
public struct vec2d:IEquatable<vec2d>
{
[FieldOffset(0)]
public float X;
[FieldOffset(sizeof(float))]
public float Y;
public Vec2D(float x,float y)
public vec2d(float x,float y)
{
X = x;
Y = y;
}
public bool Equals(Vec2D other)
public bool Equals(vec2d other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -40,13 +40,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Vec2D))
else if (obj.GetType() != typeof(vec2d))
{
return false;
}
else
{
return this.Equals((Vec2D)obj);
return this.Equals((vec2d)obj);
}
}
@@ -60,34 +60,34 @@ namespace StgSharp.Math
return $"{this.X}\t{this.Y}";
}
public static bool operator ==(Vec2D vec1, Vec2D vec2)
public static bool operator ==(vec2d vec1, vec2d vec2)
{
return vec1.X==vec2.X && vec1.Y==vec2.Y;
}
public static bool operator !=(Vec2D vec1, Vec2D vec2)
public static bool operator !=(vec2d vec1, vec2d vec2)
{
return !(vec1.X == vec2.X && vec1.Y == vec2.Y);
}
public static Vec2D operator +(Vec2D vec1, Vec2D vec2)
public static vec2d operator +(vec2d vec1, vec2d vec2)
{
return new Vec2D(vec1.X + vec2.X, vec1.Y + vec2.Y);
return new vec2d(vec1.X + vec2.X, vec1.Y + vec2.Y);
}
public static Vec2D operator -(Vec2D vec1, Vec2D vec2)
public static vec2d operator -(vec2d vec1, vec2d vec2)
{
return new Vec2D(vec1.X - vec2.X, vec1.Y - vec2.Y);
return new vec2d(vec1.X - vec2.X, vec1.Y - vec2.Y);
}
public static Vec2D operator *(Vec2D vec, float x)
public static vec2d operator *(vec2d vec, float x)
{
return new Vec2D(vec.X * x, vec.Y * x);
return new vec2d(vec.X * x, vec.Y * x);
}
public static Vec2D operator /(Vec2D vec, float x)
public static vec2d operator /(vec2d vec, float x)
{
return new Vec2D(vec.X/x, vec.Y/x);
return new vec2d(vec.X/x, vec.Y/x);
}
@@ -7,7 +7,7 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Vec3D : IEquatable<Vec3D>
public struct vec3d : IEquatable<vec3d>
{
[FieldOffset(0)]
public float X;
@@ -16,14 +16,14 @@ namespace StgSharp.Math
[FieldOffset(8)]
public float Z;
public Vec3D(float x, float y, float z)
public vec3d(float x, float y, float z)
{
X = x;
Y = y;
Z = z;
}
bool IEquatable<Vec3D>.Equals(Vec3D other)
bool IEquatable<vec3d>.Equals(vec3d other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -43,13 +43,13 @@ namespace StgSharp.Math
{
return false;
}
else if (obj.GetType() != typeof(Vec3D))
else if (obj.GetType() != typeof(vec3d))
{
return false;
}
else
{
return this.Equals((Vec3D)obj);
return this.Equals((vec3d)obj);
}
}
@@ -63,39 +63,39 @@ namespace StgSharp.Math
return $"{X}\t{Y}\t{Z}";
}
public static bool operator ==(Vec3D vec1,Vec3D vec2)
public static bool operator ==(vec3d vec1,vec3d vec2)
{
return vec1.X == vec2.X
&& vec1.Y == vec2.Y
&& vec1.Z == vec2.Z;
}
public static bool operator !=(Vec3D vec1, Vec3D vec2)
public static bool operator !=(vec3d vec1, vec3d vec2)
{
return !(vec1.X == vec2.X
&& vec1.Y == vec2.Y
&& vec1.Z == vec2.Z);
}
public static Vec3D operator +(Vec3D vec1, Vec3D vec2)
public static vec3d operator +(vec3d vec1, vec3d vec2)
{
return new Vec3D(
return new vec3d(
vec1.X + vec2.X,
vec1.Y + vec2.Y,
vec1.Z + vec2.Z
);
}
public static Vec3D operator -(Vec3D vec1, Vec3D vec2)
public static vec3d operator -(vec3d vec1, vec3d vec2)
{
return new Vec3D(
return new vec3d(
vec1.X - vec2.X,
vec1.Y - vec2.Y,
vec1.Z - vec2.Z
);
}
public static float operator *(Vec3D vec1, Vec3D vec2)
public static float operator *(vec3d vec1, vec3d vec2)
{
return
vec1.X * vec2.X
@@ -103,18 +103,18 @@ namespace StgSharp.Math
+ vec1.Z + vec2.Z;
}
public static Vec3D operator *(Vec3D vec, float x)
public static vec3d operator *(vec3d vec, float x)
{
return new Vec3D(
return new vec3d(
vec.X * x,
vec.Y * x,
vec.Z * x
);
}
public static Vec3D operator /(Vec3D vec, float x)
public static vec3d operator /(vec3d vec, float x)
{
return new Vec3D(
return new vec3d(
vec.X / x,
vec.Y / x,
vec.Z / x
@@ -9,7 +9,7 @@ using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Vec4D:IEquatable<Vec4D>
public struct vec4d:IEquatable< vec4d>
{
[FieldOffset(0)]
public float X;
@@ -22,14 +22,14 @@ namespace StgSharp.Math
[FieldOffset(0)]
public Vec2D Point1;
public vec2d Point1;
[FieldOffset(8)]
public Vec2D Point2;
public vec2d Point2;
public Vec4D(float a1,float a2,float a3,float a4)
public vec4d(float a1,float a2,float a3,float a4)
{
Point1= default(Vec2D);
Point2= default(Vec2D);
Point1= default(vec2d);
Point2= default(vec2d);
X = a1;
Y = a2;
@@ -37,7 +37,7 @@ namespace StgSharp.Math
W = a4;
}
public Vec4D(Vec2D p1,Vec2D p2)
public vec4d(vec2d p1,vec2d p2)
{
X= 0;
Y= 0;
@@ -54,17 +54,17 @@ namespace StgSharp.Math
{
return false;
}
else if(obj.GetType() != typeof(Vec4D))
else if(obj.GetType() != typeof( vec4d))
{
return false;
}
else
{
return this == (Vec4D)obj;
return this == ( vec4d)obj;
}
}
bool IEquatable<Vec4D>.Equals(Vec4D other)
bool IEquatable< vec4d>.Equals( vec4d other)
{
if (this.GetHashCode() != other.GetHashCode())
{
@@ -89,19 +89,19 @@ namespace StgSharp.Math
return $"{X}\t{Y}\t{Z}\t{W}";
}
public static bool operator ==(Vec4D vec1, Vec4D vec2)
public static bool operator ==( vec4d vec1, vec4d vec2)
{
return vec1.Equals(vec2);
}
public static bool operator !=(Vec4D vec1, Vec4D vec2)
public static bool operator !=( vec4d vec1, vec4d vec2)
{
return !vec1.Equals(vec2);
}
public static Vec4D operator +(Vec4D vec1, Vec4D vec2)
public static vec4d operator +( vec4d vec1, vec4d vec2)
{
return new Vec4D(
return new vec4d(
vec1.X + vec2.X,
vec1.Y + vec2.Y,
vec1.Z + vec2.Z,
@@ -109,9 +109,9 @@ namespace StgSharp.Math
);
}
public static Vec4D operator -(Vec4D vec1, Vec4D vec2)
public static vec4d operator -( vec4d vec1, vec4d vec2)
{
return new Vec4D(
return new vec4d(
vec1.X - vec2.X,
vec1.Y - vec2.Y,
vec1.Z - vec2.Z,
@@ -119,7 +119,7 @@ namespace StgSharp.Math
);
}
public static float operator *(Vec4D vec1, Vec4D vec2)
public static float operator *( vec4d vec1, vec4d vec2)
{
return
vec1.X * vec2.X
@@ -128,14 +128,14 @@ namespace StgSharp.Math
+ vec1.W * vec2.W;
}
public static Vec4D operator *(Vec4D vec, float x)
public static vec4d operator *( vec4d vec, float x)
{
return new Vec4D(vec.X * x, vec.Y * x, vec.Z * x, vec.W * x ) ;
return new vec4d(vec.X * x, vec.Y * x, vec.Z * x, vec.W * x ) ;
}
public static Vec4D operator /(Vec4D vec, float x)
public static vec4d operator /( vec4d vec, float x)
{
return new Vec4D(vec.X / x, vec.Y / x, vec.Z / x, vec.W / x);
return new vec4d(vec.X / x, vec.Y / x, vec.Z / x, vec.W / x);
}
+17 -9
View File
@@ -1,17 +1,30 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public class ContainerNode<T> where T : INode
public interface INode<T> where T : INode<T>
{
internal readonly T _this;
internal ContainerNode<T> ID { get; }
internal void setID<T>(ContainerNode<T> id) where T : INode<T>;
}
public class ContainerNode<T> where T : INode<T>
{
internal readonly T _value;
internal ContainerNode<T> _previous;
internal ContainerNode<T> _next;
internal ContainerNode<T> _side;
public ContainerNode(T t)
{
_value = t;
t.setID<T>(this);
}
public virtual ContainerNode<T> Previous
{
@@ -33,13 +46,8 @@ namespace StgSharp
public T Value
{
get { return _this; }
get { return _value; }
}
public ContainerNode(T t)
{
_this = t;
t.setID<T>(this);
}
}
}
-13
View File
@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public interface INode
{
internal ContainerNode<INode> ID { get; }
internal void setID<T>(ContainerNode<T> id) where T:INode;
}
}
+21 -8
View File
@@ -1,25 +1,37 @@
using System;
using StgSharp.Logic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public class LinkedList<T> where T: INode
public class LinkedList<T>:IEnumerable where T: INode
{
internal readonly ContainerNode<T> _heading;
internal ContainerNode<T> _first;
internal ContainerNode<T> _tail;
private ContainerNode<T> _cache;
public LinkedList()
{
_heading = new ContainerNode<T>(default(T));
}
public T First
{
get { return _first._this; }
set { _first = new ContainerNode<T>(value); }
get { return _first._value; }
set
{
_first = new ContainerNode<T>(value);
_heading._next = _first;
}
}
public T Tail
{
get { return _tail._this; }
get { return _tail._value; }
set { _tail = new ContainerNode<T>(value); }
}
@@ -53,8 +65,9 @@ namespace StgSharp
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return new LinkedListEnumrator<T>(this);
}
}
}
@@ -0,0 +1,35 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Logic
{
internal class LinkedListEnumrator<T> : IEnumerator where T : INode
{
private LinkedList<T> _target;
ContainerNode<T> enumrator;
public LinkedListEnumrator(LinkedList<T> target)
{
_target = target;
enumrator = target._heading;
}
object IEnumerator.Current
{
get { return enumrator._value; }
}
bool IEnumerator.MoveNext()
{
enumrator = enumrator._next;
return enumrator == default(ContainerNode<T>);
}
void IEnumerator.Reset()
{
enumrator = _target._heading;
}
}
}
+4 -3
View File
@@ -10,18 +10,19 @@ namespace StgSharp
{
public LinkedList<Point> pointContainer;
public LinkedList<IGeometry> geometryContainer;
public LinkedList<Sensor> sensorContainer;
public LinkedList<Sensor<INode>> sensorContainer;
public Line leftBoader;
public Line rightBoader;
public Line topBoader;
public Line bottomBoader;
public Pool()
{
}
public void OnRender()
{
}
+34 -14
View File
@@ -1,28 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
namespace StgSharp
{
public class Sensor : INode
{
private ContainerNode<INode> _id;
ContainerNode<INode> INode.ID
public delegate bool SensorRuleHandler(IGeometry target, IGeometry boarder);
public class Sensor<T>
{
internal IGeometry _boarder;
internal IGeometry _target;
internal SensorRuleHandler _rule;
public IGeometry boarder
{
get { return _id; }
get { return _boarder; }
}
void INode.setID<T>(ContainerNode<T> id)
public IGeometry target
{
if (id == null)
{
_id = id as ContainerNode<INode>;
}
else
{
throw new ArgumentNullException("Cannot set id teice!");
}
get { return _target; }
set { _target = value; }
}
public SensorRuleHandler Rule
{
get { return _rule; }
set { _rule = value; }
}
public static Sensor<T> operator +(Sensor<T> sensor, SensorRuleHandler rule)
{
sensor._rule += rule;
return sensor;
}
public static Sensor<T> operator -(Sensor<T> sensor, SensorRuleHandler rule)
{
sensor._rule -= rule;
return sensor;
}
}
}
+12
View File
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Math
{
public class Function
{
}
}
+12
View File
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Optimization
{
public unsafe class SSE
{
}
}
+11
View File
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Optimization
{
public static unsafe class x86
{
}
}
@@ -1 +1 @@
3a9e429a025cbd1bcea4abf9fbdb2cf05dc117a7
3e1ad1a00461e4ab0c00b4070b9447d36b0fd3cb
+193
View File
@@ -0,0 +1,193 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Runtime.InteropServices;
namespace ssd
{
public class CpuID : IDisposable
{
[UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
public delegate void CpuIDDelegate(int level, byte[] buffer);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr VirtualAlloc(
IntPtr lpAddress,
UIntPtr dwSize,
AllocationType flAllocationType,
MemoryProtection flProtect
);
[DllImport("kernel32")]
private static extern bool VirtualFree(
IntPtr lpAddress,
UInt32 dwSize,
UInt32 dwFreeType
);
[Flags()]
public enum AllocationType : uint
{
COMMIT = 0x1000,
RESERVE = 0x2000,
RESET = 0x80000,
LARGE_PAGES = 0x20000000,
PHYSICAL = 0x400000,
TOP_DOWN = 0x100000,
WRITE_WATCH = 0x200000
}
[Flags()]
public enum MemoryProtection : uint
{
EXECUTE = 0x10,
EXECUTE_READ = 0x20,
EXECUTE_READWRITE = 0x40,
EXECUTE_WRITECOPY = 0x80,
NOACCESS = 0x01,
READONLY = 0x02,
READWRITE = 0x04,
WRITECOPY = 0x08,
GUARD_Modifierflag = 0x100,
NOCACHE_Modifierflag = 0x200,
WRITECOMBINE_Modifierflag = 0x400
}
private CpuIDDelegate cpuIdDelg;
private IntPtr codePointer;
// void x86CpuId(int level, byte* buffer)
// {
// eax = level
// cpuid
// buffer[0] = eax
// buffer[4] = ebx
// buffer[8] = ecx
// buffer[12] = edx
// }
private byte[] x86CodeBytes =
{
0x55, // push ebp
0x8B, 0xEC, // mov ebp,esp
0x53, // push ebx
0x57, // push edi
0x8B, 0x45, 0x08, // mov eax, dword ptr [ebp+8] (move level into eax)
0x0F, 0xA2, // cpuid
0x8B, 0x7D, 0x0C, // mov edi, dword ptr [ebp+12] (move address of buffer into edi)
0x89, 0x07, // mov dword ptr [edi+0], eax (write eax, ... to buffer)
0x89, 0x5F, 0x04, // mov dword ptr [edi+4], ebx
0x89, 0x4F, 0x08, // mov dword ptr [edi+8], ecx
0x89, 0x57, 0x0C, // mov dword ptr [edi+12],edx
0x5F, // pop edi
0x5B, // pop ebx
0x8B, 0xE5, // mov esp,ebp
0x5D, // pop ebp
0xc3 // ret
};
private byte[] x64CodeBytes =
{
0x53, // push rbx this gets clobbered by cpuid
// rcx is level
// rdx is buffer.
// Need to save buffer elsewhere, cpuid overwrites rdx
// Put buffer in r8, use r8 to reference buffer later.
// Save rdx (buffer addy) to r8
0x49, 0x89, 0xd0, // mov r8, rdx
// Move ecx (level) to eax to call cpuid, call cpuid
0x89, 0xc8, // mov eax, ecx
0x0F, 0xA2, // cpuid
// Write eax et al to buffer
0x41, 0x89, 0x40, 0x00, // mov dword ptr [r8+0], eax
0x41, 0x89, 0x58, 0x04, // mov dword ptr [r8+4], ebx
0x41, 0x89, 0x48, 0x08, // mov dword ptr [r8+8], ecx
0x41, 0x89, 0x50, 0x0c, // mov dword ptr [r8+12], edx
0x5b, // pop rbx
0xc3 // ret
};
public CpuID()
{
Compile();
}
~CpuID()
{
Dispose(false);
}
private void Compile()
{
byte[] codeBytes;
if (IntPtr.Size == 4)
{
codeBytes = x86CodeBytes;
}
else
{
codeBytes = x64CodeBytes;
}
this.codePointer = VirtualAlloc(
IntPtr.Zero,
new UIntPtr((uint)codeBytes.Length),
AllocationType.COMMIT | AllocationType.RESERVE,
MemoryProtection.EXECUTE_READWRITE
);
Marshal.Copy(codeBytes, 0, this.codePointer, codeBytes.Length);
this.cpuIdDelg = (CpuIDDelegate)Marshal.GetDelegateForFunctionPointer(this.codePointer, typeof(CpuIDDelegate));
}
public void Invoke(int level, byte[] buffer)
{
GCHandle handle = default(GCHandle);
if (buffer.Length < 16)
{
throw new ArgumentException("buffer must be at least 16 bytes long");
}
try
{
handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
this.cpuIdDelg(level, buffer);
}
finally
{
if (handle != default(GCHandle))
{
handle.Free();
}
}
}
public void Dispose()
{
Dispose(true);
}
public void Dispose(bool disposing)
{
if (this.codePointer != IntPtr.Zero)
{
VirtualFree(this.codePointer, 0, 0x8000);
this.codePointer = IntPtr.Zero;
}
}
}
}
+1 -4
View File
@@ -8,10 +8,7 @@ internal class Program
private unsafe static void Main(string[] args)
{
float a = MathF.Sqrt(10.00f) ;
Console.WriteLine(a);
Sensor<Point> s = new Sensor<Point>();
/*
double time;
@@ -1 +1 @@
70ee143f101c68f31939cbfec5000b9894b6dc91
60e70d5da595ae3db786c2b5843f9284d9a246e2