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
Post a Comment