diff --git a/packages/cultmath/shaders/CultMath.Phacelle.hlsl b/packages/cultmath/shaders/CultMath.Phacelle.hlsl
index c95aafc6..deb47813 100644
--- a/packages/cultmath/shaders/CultMath.Phacelle.hlsl
+++ b/packages/cultmath/shaders/CultMath.Phacelle.hlsl
@@ -14,8 +14,8 @@
// against CultMath.CultPhasor, same field order.
struct CultPhasor
{
- float4 cos;
- float4 sin;
+ float4 cosine;
+ float4 sine;
};
// Johansen's Phacelle noise on 3D cells. See math.phacelle's comment (math.Phacelle.cs) for the stripe wave
@@ -84,13 +84,13 @@ CultPhasor cultmath_phacelle(float3 p, float3 side, float offset, float normaliz
float outCos = rawCos / rawLength;
float outSin = rawSin / rawLength;
float3 gradLength = (rawCos * gradRawCos + rawSin * gradRawSin) / rawLength;
- result.cos = float4((gradRawCos - outCos * gradLength) / rawLength, outCos);
- result.sin = float4((gradRawSin - outSin * gradLength) / rawLength, outSin);
+ result.cosine = float4((gradRawCos - outCos * gradLength) / rawLength, outCos);
+ result.sine = float4((gradRawSin - outSin * gradLength) / rawLength, outSin);
}
else
{
- result.cos = float4(gradRawCos / floorLength, rawCos / floorLength);
- result.sin = float4(gradRawSin / floorLength, rawSin / floorLength);
+ result.cosine = float4(gradRawCos / floorLength, rawCos / floorLength);
+ result.sine = float4(gradRawSin / floorLength, rawSin / floorLength);
}
return result;
diff --git a/packages/cultmath/src/CultMath/CultPhasor.cs b/packages/cultmath/src/CultMath/CultPhasor.cs
index fbc1f9d7..4b5b6a96 100644
--- a/packages/cultmath/src/CultMath/CultPhasor.cs
+++ b/packages/cultmath/src/CultMath/CultPhasor.cs
@@ -14,14 +14,14 @@ namespace CultMath;
public struct CultPhasor
{
/// (∇cos, cos): the normalized cosine wave and its gradient.
- public float4 cos;
+ public float4 cosine;
/// (∇sin, sin): the normalized sine wave and its gradient.
- public float4 sin;
+ public float4 sine;
- public CultPhasor(float4 cos, float4 sin)
+ public CultPhasor(float4 cosine, float4 sine)
{
- this.cos = cos;
- this.sin = sin;
+ this.cosine = cosine;
+ this.sine = sine;
}
}
diff --git a/packages/cultmath/tests/CultMath.Tests/PhacelleTests.cs b/packages/cultmath/tests/CultMath.Tests/PhacelleTests.cs
index b64f70b1..71f5b452 100644
--- a/packages/cultmath/tests/CultMath.Tests/PhacelleTests.cs
+++ b/packages/cultmath/tests/CultMath.Tests/PhacelleTests.cs
@@ -93,12 +93,12 @@ public sealed class PhacelleTests
var actual = math.phacelle(p, side, offset, normalization);
var expected = Evaluate(p, side, offset, normalization);
- maxError = Math.Max(maxError, Math.Max(Math.Abs(actual.cos.w - expected.Cos), Math.Abs(actual.sin.w - expected.Sin)));
+ maxError = Math.Max(maxError, Math.Max(Math.Abs(actual.cosine.w - expected.Cos), Math.Abs(actual.sine.w - expected.Sin)));
if (expected.RawLength >= 1.0 - normalization + ThresholdBand)
{
// The output magnitude is 1 wherever the raw magnitude reaches 1 - normalization.
above++;
- var magnitude = Math.Sqrt((double)actual.cos.w * actual.cos.w + (double)actual.sin.w * actual.sin.w);
+ var magnitude = Math.Sqrt((double)actual.cosine.w * actual.cosine.w + (double)actual.sine.w * actual.sine.w);
Assert.True(Math.Abs(magnitude - 1.0) < ValueTolerance, $"magnitude {magnitude} above the threshold at {p}");
}
else if (expected.RawLength <= 1.0 - normalization - ThresholdBand)
@@ -130,10 +130,10 @@ public sealed class PhacelleTests
var quarter = math.phacelle(p, side, offset + 0.25f, 0.5f);
var whole = math.phacelle(p, side, offset + 1.0f, 0.5f);
- Assert.True(MathF.Abs(quarter.cos.w + basePhasor.sin.w) < 2.0e-5f);
- Assert.True(MathF.Abs(quarter.sin.w - basePhasor.cos.w) < 2.0e-5f);
- Assert.True(MathF.Abs(whole.cos.w - basePhasor.cos.w) < 2.0e-5f);
- Assert.True(MathF.Abs(whole.sin.w - basePhasor.sin.w) < 2.0e-5f);
+ Assert.True(MathF.Abs(quarter.cosine.w + basePhasor.sine.w) < 2.0e-5f);
+ Assert.True(MathF.Abs(quarter.sine.w - basePhasor.cosine.w) < 2.0e-5f);
+ Assert.True(MathF.Abs(whole.cosine.w - basePhasor.cosine.w) < 2.0e-5f);
+ Assert.True(MathF.Abs(whole.sine.w - basePhasor.sine.w) < 2.0e-5f);
}
}
@@ -166,9 +166,9 @@ public sealed class PhacelleTests
if (distance > 0.0) above++; else below++;
var analytic = math.phacelle(p, side, offset, normalization);
- var numericCos = CentralDifference(q => math.phacelle(q, side, offset, normalization).cos.w, p, GradientEps);
- var numericSin = CentralDifference(q => math.phacelle(q, side, offset, normalization).sin.w, p, GradientEps);
- maxError = MathF.Max(maxError, MathF.Max(MaxComponentError(numericCos, analytic.cos), MaxComponentError(numericSin, analytic.sin)));
+ var numericCos = CentralDifference(q => math.phacelle(q, side, offset, normalization).cosine.w, p, GradientEps);
+ var numericSin = CentralDifference(q => math.phacelle(q, side, offset, normalization).sine.w, p, GradientEps);
+ maxError = MathF.Max(maxError, MathF.Max(MaxComponentError(numericCos, analytic.cosine), MaxComponentError(numericSin, analytic.sine)));
}
Assert.True(above >= 150 && below >= 150, $"{above} points above and {below} below the threshold");
@@ -199,7 +199,7 @@ public sealed class PhacelleTests
var flow = math.normalize(tangent);
var sideDirection = math.cross(hat, flow);
var phasor = math.phacelle(hat * radiusInCells, sideDirection * math.TAU, 0.25f, 0.5f);
- var gradient = new float3(phasor.cos.x, phasor.cos.y, phasor.cos.z);
+ var gradient = new float3(phasor.cosine.x, phasor.cosine.y, phasor.cosine.z);
alongFlow += Math.Abs(math.dot(gradient, flow));
acrossFlow += Math.Abs(math.dot(gradient, sideDirection));
used++;
@@ -232,7 +232,7 @@ public sealed class PhacelleTests
{
var low = math.phacelle(SetAxis(p, axis, GetAxis(p, axis) - steps[k] * 0.5f), side, offset, 0.5f);
var high = math.phacelle(SetAxis(p, axis, GetAxis(p, axis) + steps[k] * 0.5f), side, offset, 0.5f);
- maxDifference[k] = MathF.Max(maxDifference[k], MathF.Max(MathF.Abs(low.cos.w - high.cos.w), MathF.Abs(low.sin.w - high.sin.w)));
+ maxDifference[k] = MathF.Max(maxDifference[k], MathF.Max(MathF.Abs(low.cosine.w - high.cosine.w), MathF.Abs(low.sine.w - high.sine.w)));
}
}
@@ -260,8 +260,8 @@ public sealed class PhacelleTests
var pruned = math.phacelle(p, side, offset, normalization);
var unpruned = math.phacelle(p, side, offset, normalization, false);
- AssertBitEqual(unpruned.cos, pruned.cos);
- AssertBitEqual(unpruned.sin, pruned.sin);
+ AssertBitEqual(unpruned.cosine, pruned.cosine);
+ AssertBitEqual(unpruned.sine, pruned.sine);
}
}
@@ -325,8 +325,8 @@ public sealed class PhacelleTests
var pruned = math.phacelle(p, PruneCutSide, PruneCutOffset, PruneCutNormalization);
var unpruned = math.phacelle(p, PruneCutSide, PruneCutOffset, PruneCutNormalization, false);
- AssertBitEqual(unpruned.cos, pruned.cos);
- AssertBitEqual(unpruned.sin, pruned.sin);
+ AssertBitEqual(unpruned.cosine, pruned.cosine);
+ AssertBitEqual(unpruned.sine, pruned.sine);
}
}
diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl
index c95aafc6..deb47813 100644
--- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl
+++ b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl
@@ -14,8 +14,8 @@
// against CultMath.CultPhasor, same field order.
struct CultPhasor
{
- float4 cos;
- float4 sin;
+ float4 cosine;
+ float4 sine;
};
// Johansen's Phacelle noise on 3D cells. See math.phacelle's comment (math.Phacelle.cs) for the stripe wave
@@ -84,13 +84,13 @@ CultPhasor cultmath_phacelle(float3 p, float3 side, float offset, float normaliz
float outCos = rawCos / rawLength;
float outSin = rawSin / rawLength;
float3 gradLength = (rawCos * gradRawCos + rawSin * gradRawSin) / rawLength;
- result.cos = float4((gradRawCos - outCos * gradLength) / rawLength, outCos);
- result.sin = float4((gradRawSin - outSin * gradLength) / rawLength, outSin);
+ result.cosine = float4((gradRawCos - outCos * gradLength) / rawLength, outCos);
+ result.sine = float4((gradRawSin - outSin * gradLength) / rawLength, outSin);
}
else
{
- result.cos = float4(gradRawCos / floorLength, rawCos / floorLength);
- result.sin = float4(gradRawSin / floorLength, rawSin / floorLength);
+ result.cosine = float4(gradRawCos / floorLength, rawCos / floorLength);
+ result.sine = float4(gradRawSin / floorLength, rawSin / floorLength);
}
return result;
diff --git a/src/GameCult.Caching.MessagePack/CultMathJson.cs b/src/GameCult.Caching.MessagePack/CultMathJson.cs
index ba83410d..12958f03 100644
--- a/src/GameCult.Caching.MessagePack/CultMathJson.cs
+++ b/src/GameCult.Caching.MessagePack/CultMathJson.cs
@@ -511,8 +511,8 @@ public static class CultMathJson
a => new CultPhasor(new float4(a[0], a[1], a[2], a[3]), new float4(a[4], a[5], a[6], a[7])),
(v, a) =>
{
- a[0] = v.cos.x; a[1] = v.cos.y; a[2] = v.cos.z; a[3] = v.cos.w;
- a[4] = v.sin.x; a[5] = v.sin.y; a[6] = v.sin.z; a[7] = v.sin.w;
+ a[0] = v.cosine.x; a[1] = v.cosine.y; a[2] = v.cosine.z; a[3] = v.cosine.w;
+ a[4] = v.sine.x; a[5] = v.sine.y; a[6] = v.sine.z; a[7] = v.sine.w;
}),
Add(f, new Fields(("field", Xyzw()), ("curvature", Val()), ("fold", Val())),
a => new SpanNoise(new float4(a[0], a[1], a[2], a[3]), a[4], a[5]),
diff --git a/src/GameCult.Caching.MessagePack/CultMathResolver.cs b/src/GameCult.Caching.MessagePack/CultMathResolver.cs
index 95937282..02ee980c 100644
--- a/src/GameCult.Caching.MessagePack/CultMathResolver.cs
+++ b/src/GameCult.Caching.MessagePack/CultMathResolver.cs
@@ -221,7 +221,7 @@ public sealed class CultMathResolver : IFormatterResolver
}
return value;
}),
- Shape((ref MessagePackWriter w, CultPhasor v) => { w.WriteArrayHeader(2); PutFloat4(ref w, v.cos); PutFloat4(ref w, v.sin); },
+ Shape((ref MessagePackWriter w, CultPhasor v) => { w.WriteArrayHeader(2); PutFloat4(ref w, v.cosine); PutFloat4(ref w, v.sine); },
(ref MessagePackReader r) =>
{
var value = default(CultPhasor);
@@ -229,8 +229,8 @@ public sealed class CultMathResolver : IFormatterResolver
{
switch (i)
{
- case 0: value.cos = GetFloat4(ref r); break;
- case 1: value.sin = GetFloat4(ref r); break;
+ case 0: value.cosine = GetFloat4(ref r); break;
+ case 1: value.sine = GetFloat4(ref r); break;
default: r.Skip(); break;
}
}