c# - Calculating the angle and converting it to degrees -


i having trouble getting accurate angle measurement , converting degrees.

i first calculated distance with:

double distance = math.sqrt(deltax + deltay); console.writeline("distance :" + math.round(distance, 3)); console.writeline(""); 

then tried calculate angle:

double angle = math.atan2(deltay, deltax); double radiantodegree = (angle * 180 / math.pi); math.round((decimal)angle, 3); console.writeline("angle :" + angle) 

with inputs such x1=2, y1=2, x2=1, y2=1, angle should measure -135.000 degrees.

the problem not using converted value of angle.

you do:

angle = (angle * 180 / math.pi); 

instead of defining radianttodegree never using it. happens right printing angle in radians.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -