Реорганизация проекта

This commit is contained in:
Andrey Pokidov 2025-02-13 01:10:31 +07:00
parent f3b0232dd4
commit eb88fb2db4
5 changed files with 105 additions and 34 deletions

View file

@ -290,12 +290,12 @@ namespace BasicGeometry
public static void Combine(in VersorFP32 second, in VersorFP32 first, out VersorFP32 result)
{
float s0 = (second.s0 * first.s0 - second.x1 * first.x1) - (second.x2 * first.x2 + second.x3 * first.x3);
float x1 = (second.x1 * first.s0 + second.s0 * first.x1) - (second.x3 * first.x2 - second.x2 * first.x3);
float x2 = (second.x2 * first.s0 + second.s0 * first.x2) - (second.x1 * first.x3 - second.x3 * first.x1);
float x3 = (second.x3 * first.s0 + second.s0 * first.x3) - (second.x2 * first.x1 - second.x1 * first.x2);
float s0 = second.s0 * first.s0 - second.x1 * first.x1 - (second.x2 * first.x2 + second.x3 * first.x3);
float x1 = second.x1 * first.s0 + second.s0 * first.x1 - (second.x3 * first.x2 - second.x2 * first.x3);
float x2 = second.x2 * first.s0 + second.s0 * first.x2 - (second.x1 * first.x3 - second.x3 * first.x1);
float x3 = second.x3 * first.s0 + second.s0 * first.x3 - (second.x2 * first.x1 - second.x1 * first.x2);
float squareModule = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
float squareModule = s0 * s0 + x1 * x1 + (x2 * x2 + x3 * x3);
result.s0 = s0;
result.x1 = x1;
@ -323,7 +323,7 @@ namespace BasicGeometry
versor.x2 = x2;
versor.x3 = x3;
float squareModule = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
float squareModule = s0 * s0 + x1 * x1 + (x2 * x2 + x3 * x3);
if (!UtilityFP32.IsSqareValueUnit(squareModule))
{

View file

@ -49,7 +49,7 @@ public static class Program
public static int Main()
{
int amount = 1000000;
const int amount = 1000000;
VersorFP32[] versors1 = MakeRandomVersors(amount);
VersorFP32[] versors2 = MakeRandomVersors(amount);

View file

@ -1,27 +0,0 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using BasicGeometry;
namespace BasicGeometryTest
{
[TestClass]
public class TestVector2FP32
{
[TestMethod]
public void TestReset()
{
Vector2FP32 vector = new Vector2FP32(1.0f, 2.0f);
Assert.AreEqual(vector.x1, 1.0f);
Assert.AreEqual(vector.x2, 2.0f);
vector.Reset();
Assert.AreEqual(vector.x1, 0.0f);
Assert.AreEqual(vector.x2, 0.0f);
}
}
}

View file

@ -0,0 +1,48 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BasicGeometry;
namespace BasicGeometryTest
{
[TestClass]
public class Vector2InitTest
{
[TestMethod]
public void InitVector2FP32()
{
Vector2FP32 vector = new Vector2FP32(1.0f, 2.0f);
Assert.AreEqual(vector.x1, 1.0f);
Assert.AreEqual(vector.x2, 2.0f);
vector.Reset();
Assert.AreEqual(vector.x1, 0.0f);
Assert.AreEqual(vector.x2, 0.0f);
vector.SetValues(-5.02f, -200.7f);
Assert.AreEqual(vector.x1, -5.02f);
Assert.AreEqual(vector.x2, -200.7f);
}
[TestMethod]
public void InitVector2FP64()
{
Vector2FP64 vector = new Vector2FP64(1.0, 2.0);
Assert.AreEqual(vector.x1, 1.0);
Assert.AreEqual(vector.x2, 2.0);
vector.Reset();
Assert.AreEqual(vector.x1, 0.0);
Assert.AreEqual(vector.x2, 0.0);
vector.SetValues(-5.79, -200.2);
Assert.AreEqual(vector.x1, -5.79);
Assert.AreEqual(vector.x2, -200.2);
}
}
}

View file

@ -0,0 +1,50 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BasicGeometry;
namespace BasicGeometryTest.Vector2
{
[TestClass]
public class Vector2IsZeroTest
{
[TestMethod]
public void IsZeroFP32()
{
Vector2FP32 vector = new Vector2FP32();
Assert.IsTrue(vector.IsZero());
vector.SetValues(UtilityFP32.EPSYLON * 0.75f, 0.0f);
Assert.IsTrue(vector.IsZero());
vector.SetValues(-UtilityFP32.EPSYLON * 0.5f, -UtilityFP32.EPSYLON * 0.5f);
Assert.IsTrue(vector.IsZero());
vector.SetValues(-UtilityFP32.EPSYLON * 1.25f, -UtilityFP32.EPSYLON * 1.25f);
Assert.IsFalse(vector.IsZero());
}
[TestMethod]
public void IsZeroFP64()
{
Vector2FP64 vector = new Vector2FP64();
Assert.IsTrue(vector.IsZero());
vector.SetValues(UtilityFP64.EPSYLON * 0.75, 0.0);
Assert.IsTrue(vector.IsZero());
vector.SetValues(-UtilityFP64.EPSYLON * 0.5, UtilityFP64.EPSYLON * 0.5);
Assert.IsTrue(vector.IsZero());
vector.SetValues(UtilityFP64.EPSYLON * 1.25, UtilityFP64.EPSYLON * 1.25);
Assert.IsFalse(vector.IsZero());
}
}
}