runelite-api: move rotate() to Vertex
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user