XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Numerics;
using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Rendering;
using XFEExtension.NetCore.XUnit.Attributes;

namespace XFEEDToolBox.Test;

[TestFixture]
public sealed class GalaxyOriginalPowerActivityBillboardTests
{
    [Test] public void BillboardUsesItsOwnExtentAndActualTangentAllocation()
    {
        var bound=new GalaxyNativePowerOuter(null,9007199254740993,new(100,20,30),100){Extent=10};
        Check.That(GalaxyOriginalPowerActivityBillboardGeometry.TryCreate(bound,new(100,20,80),out var value));
        var expected=10f*(50f/MathF.Sqrt(2500-100))*GalaxyOriginalPowerActivityBillboardGeometry.AllocationMultiplier;
        Check.That(Math.Abs(value.UAxisExtent.W-expected)<.00001f&&value.UAxisExtent.W!=bound.Radius);
        Check.Equal(100f,value.Position.X);Check.Equal(20f,value.Position.Y);Check.Equal(0f,value.Colour.W);
    }
    [Test] public void MissingOrZeroExtentAndInsideEyeNeverInventContourFromRadius()
    {
        var bound=new GalaxyNativePowerOuter(true,7,new(0,0,0),100);
        Check.That(!GalaxyOriginalPowerActivityBillboardGeometry.TryCreate(bound,new(0,0,200),out _));
        Check.That(!GalaxyOriginalPowerActivityBillboardGeometry.TryCreate(bound with{Extent=0},new(0,0,200),out _));
        Check.That(!GalaxyOriginalPowerActivityBillboardGeometry.TryCreate(bound with{Extent=10},new(0,0,10),out _));
    }
    [Test] public void OriginalBasisBranchesAreOrthonormalIncludingAxisAndTieDirections()
    {
        var bound=new GalaxyNativePowerOuter(null,7,new(0,0,0),100){Extent=1};
        foreach(var eye in new[]{new Vector3(10,0,0),new(0,10,0),new(0,0,10),new(10,10,10),new(-3,8,5)})
        {
            Check.That(GalaxyOriginalPowerActivityBillboardGeometry.TryCreate(bound,new(eye.X,eye.Y,eye.Z),out var value));
            var u=new Vector3(value.UAxisExtent.X,value.UAxisExtent.Y,value.UAxisExtent.Z);var v=new Vector3(value.VAxisExtent.X,value.VAxisExtent.Y,value.VAxisExtent.Z);
            Check.That(Math.Abs(u.Length()-1)<.000001&&Math.Abs(v.Length()-1)<.000001&&Math.Abs(Vector3.Dot(u,v))<.000001);
            Check.That(Math.Abs(Vector3.Dot(u,Vector3.Normalize(eye)))<.000001&&Math.Abs(Vector3.Dot(v,Vector3.Normalize(eye)))<.000001);
        }
    }
}