summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2017-09-30 02:39:01 -0500
committerepoch <epoch@hacking.allowed.org>2017-09-30 02:39:01 -0500
commitd191e11c4e48cced1346f92dc76ce7bc109679e2 (patch)
treea4ef26501f107efa8d434452a2fb26a89af2b5c6 /src
parentf0fc2460f183d0d8c0bef7936f5576bbc27283df (diff)
downloadhackvr-d191e11c4e48cced1346f92dc76ce7bc109679e2.tar.gz
hackvr-d191e11c4e48cced1346f92dc76ce7bc109679e2.zip
fixed rotate_c2 to use the right trig functions for x and y and to use the right order in its points_to_angle
Diffstat (limited to 'src')
-rw-r--r--src/math.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/math.c b/src/math.c
index 7c7fff4..82328b7 100644
--- a/src/math.c
+++ b/src/math.c
@@ -35,15 +35,14 @@ c3_t rotate_c3_zr(c3_t p1,c3_t p2,radians zr) {//rotate x and y around camera ba
//sin(90deg) = 1
//cos(0) = 1
//cos(90deg) = 0
-c2_t rotate_c2(c2_t p1,c2_t p2,radians dr) {//dr is in radians
+//// rotate first point about second point
+c2_t rotate_c2(c2_t p1,c2_t p2,radians dr) {
c2_t p3;
real d=distance2(p1,p2);
- radians r=points_to_angle(p1,p2);
+ radians r=points_to_angle(p2,p1);
r.r=r.r+dr.r;
- p3.x=(sinl(r.r) * d) + p2.x;//switchiing this to cos and the next line to sin seems
- p3.y=(cosl(r.r) * d) + p2.y;//to make some bug less weird.
-// p3.x=(cosl(r.r) * d) + p2.x;//switchiing this to cos and the next line to sin seems
-// p3.y=(sinl(r.r) * d) + p2.y;//to make some bug less weird.
+ p3.x=(cosl(r.r) * d) + p2.x;
+ p3.y=(sinl(r.r) * d) + p2.y;
return p3;
}
real distance2(c2_t p1,c2_t p2) {
@@ -54,6 +53,7 @@ radians d2r(degrees d) {
while(d.d<0) d.d+=360;
return (radians){(real)(d.d%360) / (real)180 * M_PIl};
}
+//the angle from the first point to the second point. not the other way around.
radians points_to_angle(c2_t p1,c2_t p2) {
real a=atan2l(p2.y-p1.y,p2.x-p1.x);
return (radians){a>=0?a:M_PIl+M_PIl+a};