Skip to content

Commit b9ae140

Browse files
committed
mt mat, plane ray
1 parent d3eb0f9 commit b9ae140

File tree

18 files changed

+45970
-2
lines changed

18 files changed

+45970
-2
lines changed

Coplt.Mathematics.Simt/Geometries/plane.cs

Lines changed: 1725 additions & 0 deletions
Large diffs are not rendered by default.

Coplt.Mathematics.Simt/Geometries/plane.tt

Lines changed: 328 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
// generated by template, do not modify manually
2+
3+
namespace Coplt.Mathematics.Simt.Geometries;
4+
5+
#region ray_mt4
6+
7+
[CpuOnly]
8+
public partial struct ray_mt4
9+
{
10+
/// <summary>The origin point of the ray.</summary>
11+
public float3_mt4 origin;
12+
13+
/// <summary>The direction of the ray.</summary>
14+
public float3_mt4 direction;
15+
16+
[MethodImpl(256 | 512)]
17+
public ray_mt4(float3_mt4 origin, float3_mt4 direction)
18+
{
19+
this.origin = origin;
20+
this.direction = direction;
21+
}
22+
23+
/// <summary>
24+
/// Returns a point at distance units along the ray.
25+
/// </summary>
26+
[MethodImpl(256 | 512)]
27+
public readonly float3_mt4 point_at(float_mt4 distance) => direction.fma(distance, origin);
28+
}
29+
30+
#endregion // ray_mt4
31+
#region ray_mt8
32+
33+
[CpuOnly]
34+
public partial struct ray_mt8
35+
{
36+
/// <summary>The origin point of the ray.</summary>
37+
public float3_mt8 origin;
38+
39+
/// <summary>The direction of the ray.</summary>
40+
public float3_mt8 direction;
41+
42+
[MethodImpl(256 | 512)]
43+
public ray_mt8(float3_mt8 origin, float3_mt8 direction)
44+
{
45+
this.origin = origin;
46+
this.direction = direction;
47+
}
48+
49+
/// <summary>
50+
/// Returns a point at distance units along the ray.
51+
/// </summary>
52+
[MethodImpl(256 | 512)]
53+
public readonly float3_mt8 point_at(float_mt8 distance) => direction.fma(distance, origin);
54+
}
55+
56+
#endregion // ray_mt8
57+
#region ray_mt16
58+
59+
[CpuOnly]
60+
public partial struct ray_mt16
61+
{
62+
/// <summary>The origin point of the ray.</summary>
63+
public float3_mt16 origin;
64+
65+
/// <summary>The direction of the ray.</summary>
66+
public float3_mt16 direction;
67+
68+
[MethodImpl(256 | 512)]
69+
public ray_mt16(float3_mt16 origin, float3_mt16 direction)
70+
{
71+
this.origin = origin;
72+
this.direction = direction;
73+
}
74+
75+
/// <summary>
76+
/// Returns a point at distance units along the ray.
77+
/// </summary>
78+
[MethodImpl(256 | 512)]
79+
public readonly float3_mt16 point_at(float_mt16 distance) => direction.fma(distance, origin);
80+
}
81+
82+
#endregion // ray_mt16
83+
#region ray_d_mt4
84+
85+
[CpuOnly]
86+
public partial struct ray_d_mt4
87+
{
88+
/// <summary>The origin point of the ray.</summary>
89+
public double3_mt4 origin;
90+
91+
/// <summary>The direction of the ray.</summary>
92+
public double3_mt4 direction;
93+
94+
[MethodImpl(256 | 512)]
95+
public ray_d_mt4(double3_mt4 origin, double3_mt4 direction)
96+
{
97+
this.origin = origin;
98+
this.direction = direction;
99+
}
100+
101+
/// <summary>
102+
/// Returns a point at distance units along the ray.
103+
/// </summary>
104+
[MethodImpl(256 | 512)]
105+
public readonly double3_mt4 point_at(double_mt4 distance) => direction.fma(distance, origin);
106+
}
107+
108+
#endregion // ray_d_mt4
109+
#region ray_d_mt8
110+
111+
[CpuOnly]
112+
public partial struct ray_d_mt8
113+
{
114+
/// <summary>The origin point of the ray.</summary>
115+
public double3_mt8 origin;
116+
117+
/// <summary>The direction of the ray.</summary>
118+
public double3_mt8 direction;
119+
120+
[MethodImpl(256 | 512)]
121+
public ray_d_mt8(double3_mt8 origin, double3_mt8 direction)
122+
{
123+
this.origin = origin;
124+
this.direction = direction;
125+
}
126+
127+
/// <summary>
128+
/// Returns a point at distance units along the ray.
129+
/// </summary>
130+
[MethodImpl(256 | 512)]
131+
public readonly double3_mt8 point_at(double_mt8 distance) => direction.fma(distance, origin);
132+
}
133+
134+
#endregion // ray_d_mt8
135+
#region ray_d_mt16
136+
137+
[CpuOnly]
138+
public partial struct ray_d_mt16
139+
{
140+
/// <summary>The origin point of the ray.</summary>
141+
public double3_mt16 origin;
142+
143+
/// <summary>The direction of the ray.</summary>
144+
public double3_mt16 direction;
145+
146+
[MethodImpl(256 | 512)]
147+
public ray_d_mt16(double3_mt16 origin, double3_mt16 direction)
148+
{
149+
this.origin = origin;
150+
this.direction = direction;
151+
}
152+
153+
/// <summary>
154+
/// Returns a point at distance units along the ray.
155+
/// </summary>
156+
[MethodImpl(256 | 512)]
157+
public readonly double3_mt16 point_at(double_mt16 distance) => direction.fma(distance, origin);
158+
}
159+
160+
#endregion // ray_d_mt16
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<#@ template language="C#" #>
2+
<#@ output extension=".cs" #>
3+
<#@ import namespace="System.Text" #>
4+
<#@ import namespace="System.Collections.Generic" #>
5+
<#@ include file="../../Coplt.Mathematics/types.ttinclude" #><#@ import namespace="System.Linq" #>// generated by template, do not modify manually
6+
7+
namespace Coplt.Mathematics.Simt.Geometries;
8+
9+
<#
10+
var sizes = new[] { 4, 8, 16 };
11+
12+
foreach (var typ in Typ.Typs)
13+
{
14+
if (!typ.simd) continue;
15+
if (typ.size < 4) continue;
16+
if (!typ.f || !typ.bin) continue;
17+
18+
foreach (var size in sizes)
19+
{
20+
var byteSize = 4 * size;
21+
var bitSize = 8 * byteSize;
22+
var num_vectors = Math.Max(1, bitSize / 512);
23+
bitSize = Math.Min(512, bitSize);
24+
25+
var scalarName = $"{typ.compType}_mt{size}";
26+
var vectorName = $"{typ.name}3_mt{size}";
27+
var typeName = $"ray{typ.structSuffix}_mt{size}";
28+
29+
IEnumerable<string> ForVectors(string name)
30+
{
31+
if (num_vectors == 1) yield return name;
32+
else
33+
{
34+
for (var i = 0; i < num_vectors; i++)
35+
{
36+
yield return $"{name}{i}";
37+
}
38+
}
39+
}
40+
41+
var vectors = ForVectors("vector").ToList();
42+
#>
43+
#region <#= typeName #>
44+
45+
[CpuOnly]
46+
public partial struct <#= typeName #>
47+
{
48+
/// <summary>The origin point of the ray.</summary>
49+
public <#= vectorName #> origin;
50+
51+
/// <summary>The direction of the ray.</summary>
52+
public <#= vectorName #> direction;
53+
54+
[MethodImpl(256 | 512)]
55+
public <#= typeName #>(<#= vectorName #> origin, <#= vectorName #> direction)
56+
{
57+
this.origin = origin;
58+
this.direction = direction;
59+
}
60+
61+
/// <summary>
62+
/// Returns a point at distance units along the ray.
63+
/// </summary>
64+
[MethodImpl(256 | 512)]
65+
public readonly <#= vectorName #> point_at(<#= scalarName #> distance) => direction.fma(distance, origin);
66+
}
67+
68+
#endregion // <#= typeName #>
69+
<#
70+
}
71+
}
72+
#>

0 commit comments

Comments
 (0)