Guest User

converting polar equation to rectangular form // omrii

a guest
May 5th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// obj_ball step event
  2.  
  3. angle = ((angle + (1/2)) % 180);
  4.  
  5. var arcHeight = 144;
  6.  
  7. //gotta do this weird hack since gm:s can't handle imaginary numbers.
  8. if((angle >= 0) && (angle <= 45))
  9. {
  10.     radius = arcHeight*sqrt(dcos(2*angle));
  11.    
  12.     tarx = (view_wview[0]/2) + radius*dcos(angle);
  13.     tary = (view_hview[0]/2) + radius*dsin(angle);
  14.  
  15. }
  16. else if((angle > 45) && (angle < 135))
  17. {
  18.     radius = arcHeight*sqrt(dcos(2*(225 - (angle-45))));
  19.     tarx = (view_wview[0]/2) + radius*dcos(angle+90);
  20.     tary = (view_hview[0]/2) - radius*dsin(angle+90);   // if u wanna have the balls "bound" instead
  21.                                                         // of corssing change the - to a + here
  22. }
  23. else if((angle >= 135) && (angle < 180))
  24. {
  25.     radius = arcHeight*sqrt(dcos(2*(angle)));
  26.     tarx = (view_wview[0]/2) - radius*dcos(angle);
  27.     tary = (view_hview[0]/2) - radius*dsin(angle);
  28. }
  29.  
  30. x = tarx;
  31. y = tary;
Advertisement
Add Comment
Please, Sign In to add comment