From beb8c2460ef60676be64cba8cebcfb6d05f11ea6 Mon Sep 17 00:00:00 2001 From: zyb3rwolfi Date: Tue, 23 Sep 2025 13:18:18 +0100 Subject: [PATCH] Completed vector resting --- TheRepo/.idea/.idea.TheRepo/.idea/.gitignore | 13 +++++++++ TheRepo/.idea/.idea.TheRepo/.idea/discord.xml | 7 +++++ .../.idea/.idea.TheRepo/.idea/encodings.xml | 4 +++ .../.idea/.idea.TheRepo/.idea/indexLayout.xml | 10 +++++++ TheRepo/.idea/.idea.TheRepo/.idea/vcs.xml | 7 +++++ TheRepo/TheLabs/MyVector.cs | 28 +++++++++++++++---- .../VectorAndMatrixTests.csproj | 1 + 7 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 TheRepo/.idea/.idea.TheRepo/.idea/.gitignore create mode 100644 TheRepo/.idea/.idea.TheRepo/.idea/discord.xml create mode 100644 TheRepo/.idea/.idea.TheRepo/.idea/encodings.xml create mode 100644 TheRepo/.idea/.idea.TheRepo/.idea/indexLayout.xml create mode 100644 TheRepo/.idea/.idea.TheRepo/.idea/vcs.xml diff --git a/TheRepo/.idea/.idea.TheRepo/.idea/.gitignore b/TheRepo/.idea/.idea.TheRepo/.idea/.gitignore new file mode 100644 index 0000000..ec8dec9 --- /dev/null +++ b/TheRepo/.idea/.idea.TheRepo/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/contentModel.xml +/.idea.TheRepo.iml +/projectSettingsUpdater.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/TheRepo/.idea/.idea.TheRepo/.idea/discord.xml b/TheRepo/.idea/.idea.TheRepo/.idea/discord.xml new file mode 100644 index 0000000..d8e9561 --- /dev/null +++ b/TheRepo/.idea/.idea.TheRepo/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/TheRepo/.idea/.idea.TheRepo/.idea/encodings.xml b/TheRepo/.idea/.idea.TheRepo/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/TheRepo/.idea/.idea.TheRepo/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TheRepo/.idea/.idea.TheRepo/.idea/indexLayout.xml b/TheRepo/.idea/.idea.TheRepo/.idea/indexLayout.xml new file mode 100644 index 0000000..74e7854 --- /dev/null +++ b/TheRepo/.idea/.idea.TheRepo/.idea/indexLayout.xml @@ -0,0 +1,10 @@ + + + + + ../../551455-graphics-programming-2526-the-repo-Zyb3rWolfi + + + + + \ No newline at end of file diff --git a/TheRepo/.idea/.idea.TheRepo/.idea/vcs.xml b/TheRepo/.idea/.idea.TheRepo/.idea/vcs.xml new file mode 100644 index 0000000..62bd7a0 --- /dev/null +++ b/TheRepo/.idea/.idea.TheRepo/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/TheRepo/TheLabs/MyVector.cs b/TheRepo/TheLabs/MyVector.cs index 43c4574..5505851 100644 --- a/TheRepo/TheLabs/MyVector.cs +++ b/TheRepo/TheLabs/MyVector.cs @@ -53,23 +53,41 @@ public class MyVector } public MyVector Normalise() { - return null; + float mag = Magnitude(); + + return new MyVector(X / mag, Y / mag, Z / mag); } public float DotProduct(MyVector pVector) { - return -1; + float dotProduct = (X * pVector.X) + (Y * pVector.Y) + (Z * pVector.Z); + return dotProduct; } public MyVector Interpolate(MyVector pVector, float pInterpolation) { - return null; + return new MyVector( + X + (pVector.X - X) * pInterpolation, + Y + (pVector.Y - Y) * pInterpolation, + Z + (pVector.Z - Z) * pInterpolation + ); } public float AngleBetween(MyVector pVector) { - return -1; + float dot = DotProduct(pVector); + float magA = Magnitude(); + float magB = pVector.Magnitude(); + + float cosAngle = dot / (magA * magB); + cosAngle = Math.Clamp(cosAngle, -1.0f, 1.0f); + + return (float)Math.Acos(cosAngle); } public MyVector CrossProduct(MyVector pVector) { - return null; + return new MyVector( + (Y * pVector.Z) - (Z * pVector.Y), + (Z * pVector.X) - (X * pVector.Z), + (X * pVector.Y) - (Y * pVector.X) + ); } } diff --git a/TheRepo/VectorAndMatrixTests/VectorAndMatrixTests.csproj b/TheRepo/VectorAndMatrixTests/VectorAndMatrixTests.csproj index 256ff32..cf249a0 100644 --- a/TheRepo/VectorAndMatrixTests/VectorAndMatrixTests.csproj +++ b/TheRepo/VectorAndMatrixTests/VectorAndMatrixTests.csproj @@ -14,6 +14,7 @@ +