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 c6c05bd

Browse files
committed
implement matrix shear behavior
1 parent 9926bd2 commit c6c05bd

File tree

4 files changed

+12377
-3
lines changed

4 files changed

+12377
-3
lines changed

‎Assets/Scripts/HolisticMath.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ static public Coords Rotate(Coords position, float angleX, bool clockwiseX,
146146
return mQ.AsCoords();
147147
}
148148

149+
static public Coords Shear(Coords position, Vector3 shear)
150+
{
151+
Matrix mQ;
152+
Matrix mS = new Matrix(4, 4, new float[16] { 1, shear.y, shear.z, 0, shear.x, 1, shear.z, 0, shear.x, shear.y, 1, 0, 0, 0, 0, 1 });
153+
Matrix mP = new Matrix(4, 1, position.AsFloats());
154+
155+
mQ = mS * mP;
156+
return mQ.AsCoords();
157+
}
158+
149159
static public Coords Cross(Coords vector1, Coords vector2)
150160
{
151161
float xMult = vector1.y * vector2.z - vector1.z * vector2.y;

‎Assets/Transformations.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class Transformations : MonoBehaviour
66
public Vector3 translation;
77
public Vector3 scaling;
88
public Vector3 rotation;
9+
public Vector3 shear;
910
public GameObject center;
1011

1112
void Start()
@@ -18,12 +19,13 @@ void Start()
1819
{
1920
Coords position = new Coords(point.transform.position, 1);
2021

21-
position = HolisticMath.Translate(position, new Coords(new Vector3(-c.x, -c.y, -c.z), 0));
22-
position = HolisticMath.Rotate(position, rotation.x, true, rotation.y, true, rotation.z, true);
23-
point.transform.position = HolisticMath.Translate(position, new Coords(new Vector3(c.x, c.y, c.z), 0)).ToVector();
22+
point.transform.position = HolisticMath.Shear(position, shear).ToVector();
2423

2524
/*
2625
26+
position = HolisticMath.Translate(position, new Coords(new Vector3(-c.x, -c.y, -c.z), 0));
27+
position = HolisticMath.Rotate(position, rotation.x, true, rotation.y, true, rotation.z, true);
28+
point.transform.position = HolisticMath.Translate(position, new Coords(new Vector3(c.x, c.y, c.z), 0)).ToVector();
2729
position = HolisticMath.Scale(position, new Coords(new Vector3(scaling.x, scaling.y, scaling.z)));
2830
2931
*/

0 commit comments

Comments
(0)

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