runelite-api: move rotate() to Vertex

This commit is contained in:
Adam
2017-08-12 22:26:43 -04:00
parent 04e84e9921
commit 409aa9eb1f
2 changed files with 22 additions and 15 deletions

View File

@@ -128,24 +128,12 @@ public class Player extends Actor
Vertex c = triangle.getC();
Triangle rotatedTriangle = new Triangle(
rotate(a, orientation),
rotate(b, orientation),
rotate(c, orientation)
a.rotate(orientation),
b.rotate(orientation),
c.rotate(orientation)
);
rotatedTriangles.add(rotatedTriangle);
}
return rotatedTriangles;
}
private Vertex rotate(Vertex vertex, int orientation)
{
int sin = Perspective.SINE[orientation];
int cos = Perspective.COSINE[orientation];
return new Vertex(
vertex.getX() * cos + vertex.getZ() * sin >> 16,
vertex.getY(),
vertex.getZ() * cos - vertex.getX() * sin >> 16
);
}
}

View File

@@ -24,6 +24,8 @@
*/
package net.runelite.api.model;
import net.runelite.api.Perspective;
public class Vertex
{
private final int x;
@@ -94,4 +96,21 @@ public class Vertex
{
return z;
}
/**
* Rotate the vertex by the given orientation
* @param orientation
* @return the newly rotated vertex
*/
public Vertex rotate(int orientation)
{
int sin = Perspective.SINE[orientation];
int cos = Perspective.COSINE[orientation];
return new Vertex(
x * cos + z * sin >> 16,
y,
z * cos - x * sin >> 16
);
}
}