mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Signed angles
This commit is contained in:
parent
5a482f4d38
commit
73d70527f3
@ -115,6 +115,13 @@ public abstract class Spline {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 2 dimensional "cross" product. cross2D(v1, v2) = |v1|*|v2|*sin(theta) or v1 X v2 taking Y to be 0
|
||||
*/
|
||||
private double cross2D(Vector2 v1, Vector2 v2) {
|
||||
return v1.getX() * v2.getZ() - v2.getX() * v1.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paste structure at the provided position on the curve. The position will not be position-corrected
|
||||
* but will be passed directly to the interpolation algorithm.
|
||||
@ -136,7 +143,7 @@ public abstract class Spline {
|
||||
Vector3 deriv = interpolation.get1stDerivative(position);
|
||||
Vector2 deriv2D = Vector2.at(deriv.getX(), deriv.getZ()).normalize();
|
||||
double angle = Math.toDegrees(
|
||||
-Math.acos(direction.dot(deriv2D))
|
||||
-Math.atan2(cross2D(direction, deriv2D), direction.dot(deriv2D))
|
||||
);
|
||||
|
||||
angle = ((angle % 360) + 360) % 360; // Wrap to 360 degrees
|
||||
|
Loading…
Reference in New Issue
Block a user