Skip to content

Commit

Permalink
123
Browse files Browse the repository at this point in the history
  • Loading branch information
YESshowMeCode committed Apr 28, 2019
1 parent 9ac9d4a commit b31c9c3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions SoftRender/Math/Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public float length
}
}

public void Normalize()
{
x = x / length;
y = y / length;
z = z / length;
}

public static Vector operator +(Vector right, Vector left)
{
Vector vec = new Vector();
Expand All @@ -69,6 +76,21 @@ public float length
return new Vector(right.x * f, right.y * f, right.z * f);
}

public static Vector operator /(Vector right,float f)
{
return new Vector(right.x / f, right.y / f, right.z / f);
}

public Vector MultiplyMatrix(Matrix matrix)
{
Vector vec = new Vector();
vec.x = x * matrix[0, 0] + y * matrix[0, 1] + z * matrix[0, 2] + w * matrix[0, 3];
vec.y = x * matrix[1, 0] + y * matrix[1, 1] + z * matrix[1, 2] + w * matrix[1, 3];
vec.z = x * matrix[2, 0] + y * matrix[2, 1] + z * matrix[2, 1] + w * matrix[2, 3];
vec.w = x * matrix[3, 0] + y * matrix[3, 1] + z * matrix[3, 2] + w * matrix[3, 3];
return vec;
}

public static float Dot(Vector right, Vector left)
{
return right.x * left.x + right.y * left.y + right.z * left.z;
Expand Down
Binary file modified SoftRender/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Binary file not shown.
Binary file not shown.

0 comments on commit b31c9c3

Please sign in to comment.