|
Re: Geometry & Trig Quiz
From my reasoning, the code only crashes due to a division by zero in the arctangent function. This could be fixed by using arcsin ((x1-x0)/sqrt ((x1-x0)^2+(y1-y0)^2)). This crashes if the inital and final positions are the same, but the problem is meaningless if you are already at yor final position.
Regarding the smallest Delta, either a conditional check on the absolute value of Delta being larger than 180 degrees or running the delta through arcsin(sin(Delta)) could do the trick. I know the second suggestion is implemetation dependent and not the ideal method but it is a method that I think will work in most cases.
__________________
2016:
Alamo, Bayou, and Lone Star Regional FTAA
2015:
Dallas, Alamo, Bayou, and Lone Star Regional FTAA
2014:
Alamo, Dallas, and Lone Star Regional FTAA
Alamo Regional Robot Inspector
2013:
Einstein Champion and 2013 World Champion (Thanks 1241 & 610), Galileo Division Champion, Razorback Regional Winner, Alamo Regional Semifinalist, Bayou Regional Semifinalist, Lone Star Regional Quarterfinialist
2012:
Curie Division Semifinalist, Lone Star Regional Finalist, Bayou Regional Winner, Alamo Regional Winner
Last edited by Aaron.Graeve : 26-10-2013 at 19:40.
|