Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b64c9de

Browse files
committed
add W variable to coords class and method to return a coord as a float array
1 parent caddeec commit b64c9de

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

‎Assets/Scripts/Coords.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class Coords
88
public float x;
99
public float y;
1010
public float z;
11+
public float w;
1112

1213
public Coords(float _X, float _Y)
1314
{
@@ -23,13 +24,36 @@ public Coords(float _X, float _Y, float _Z)
2324
z = _Z;
2425
}
2526

27+
public Coords(float _X, float _Y, float _Z, float _W)
28+
{
29+
x = _X;
30+
y = _Y;
31+
z = _Z;
32+
w = _W;
33+
}
34+
2635
public Coords(Vector3 vecpos)
2736
{
2837
x = vecpos.x;
2938
y = vecpos.y;
3039
z = vecpos.z;
3140
}
3241

42+
43+
public Coords(Vector3 vecpos, float _W)
44+
{
45+
x = vecpos.x;
46+
y = vecpos.y;
47+
z = vecpos.z;
48+
w = _W;
49+
}
50+
51+
public float[] AsFloats()
52+
{
53+
float[] values = { x, y, z, w };
54+
return values;
55+
}
56+
3357
public Coords GetNormal()
3458
{
3559
float magnitude = HolisticMath.Distance(new Coords(0, 0, 0), new Coords(x, y, z));

‎Assets/Scripts/Matrix.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ public Matrix(int r, int c, float[] v)
1414
Array.Copy(v, values, rows * cols);
1515
}
1616

17+
public Coords AsCoords()
18+
{
19+
if (rows == 4 && cols == 1)
20+
{
21+
return new Coords(values[0], values[1], values[2], values[3]);
22+
}
23+
else
24+
{
25+
return null;
26+
}
27+
}
28+
1729
public override string ToString()
1830
{
1931
string matrix = "";

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /