Python Forum
Converting Angle to X and Y Values: 90/180/270 deg
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting Angle to X and Y Values: 90/180/270 deg
#1
So I have a way to turn an angle into x and y values:
angle = math.radians(0)
y = math.cos(angle)
x = math.sin(angle)
print(x,y)
and it prints:
Output:
0.0 1.0
but then, I change they 0 to 90:
angle = math.radians(90)
y = math.cos(angle)
x = math.sin(angle)
print(x,y)
and would expect to have 1.0 0.0 as the output, but got this:
Output:
1.0 6.123233995736766e-17
which is a super miniscule number, but why isn't it 1.0 0.0?
and how can I make it right?
Reply
#2
http://docs.python.org/tutorial/floatingpoint.html or
http://www.lahey.com/float.htm
Quote:how can I make it right?
Use Python's decimal module for more precision than a floating point.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting column of values into muliple columns of counts highland44 0 251 Feb-01-2024, 12:48 AM
Last Post: highland44
  Trouble with converting list , dict to int values! faryad13 7 3,744 Sep-04-2020, 06:25 AM
Last Post: faryad13
  How to map 360 degree angle over 1024 counts breadcat248 3 2,499 May-17-2019, 07:13 AM
Last Post: breadcat248
  finding angle between three points on a 2d graph qrani 4 14,071 Nov-20-2018, 06:10 AM
Last Post: Gribouillis
  Angle kripso 12 31,493 Oct-30-2017, 11:33 PM
Last Post: kripso
  How to find the cosine of an angle sylas 6 5,193 May-25-2017, 04:29 PM
Last Post: sylas

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020