Академический Документы
Профессиональный Документы
Культура Документы
Ian Parberry
University of North Texas
Chapter 7 )otes
"
Word Cloud
Chapter 7 )otes
&
Section 7.!-
Chapter 7 )otes
Chapter 7 )otes
Chapter 7 )otes
Polar Coordinates
In Cartesian coordinates %e described a "D point usin# the usin# t%o si#ned distances2 x and y. Polar coordinates use a distance and an an#le. 8y convention2 the distance is usually called r 0%hich is short or radi s1 and the an#le is usually called 9. The polar coordinate pair 0r2 91 species a point in "D space as ollo%s!. Start at the ori#in2 acin# in the direction o the polar a$is2 and rotate by an#le 9. Positive values o 9 are usually interpreted to mean countercloc'%ise rotation2 %ith ne#ative values indicatin# cloc'%ise rotation. ". )o% move or%ard rom the ori#in a distance o r units.
Chapter 7 )otes
Chapter 7 )otes
;$amples
Chapter 7 )otes
<
Polar Dia#rams
The #rid circles sho% lines o constant r. The strai#ht #rid lines that pass throu#h the ori#in sho% lines o constant 92 consistin# o points that are the same direction rom the ori#in.
Chapter 7 )otes
!=
/n#ular *easurement
It really doesn4t matter %hether you use de#rees or radians 0or #rads2 mils2 minutes2 si#ns2 se$tants2 or Furmans1 to measure an#les2 so lon# as you 'eep it strai#ht. In the te$t o our boo' %e almost al%ays #ive speci ic an#ular measurements in de#rees and use the > symbol a ter the number. We do this because %e are human bein#s2 and most humans %ho are not math pro essors ind it easier to deal %ith %hole numbers rather than ractions o ?. Indeed2 the choice o the number &7= %as speci ically desi#ned to ma'e ractions avoidable in many common cases. @o%ever2 computers pre er to %or' %ith an#les e$pressed usin# radians2 and so the code snippets in our boo' use radians rather than de#rees.
Chapter 7 )otes
!!
Chapter 7 )otes
!"
/liasin#
The ans%er to all o these Guestions is HyesI. In act2 or any #iven point2 there are in initely many polar coordinate pairs that can be used to describe that point. This phenomenon is 'no%n as aliasin!. T%o coordinate pairs are said to be aliases o each other i they have di erent numeric values but re er to the same point in space. )otice that aliasin# doesn4t happen in Cartesian space. ;ach point in space is assi#ned e$actly one 0x2 y1 coordinate pair. / #iven point in polar space corresponds to many coordinate pairs2 but a coordinate pair unambi#uously desi#nates e$actly one point.
Chapter 7 )otes
!&
Creatin# /liases
Jne %ay to create an alias or a point 0 r2 91 is to add a multiple o &7=> to 9. Thus 0r2 91 and 0r2 9 3 "&7=>1 describe the same point2 %here " is an inte#er. We can also #enerate an alias by addin# !:=> to 9 and ne#atin# rK %hich means %e ace the other direction2 but %e displace by the opposite amount. In #eneral2 or any point 0r2 91 other than the ori#in2 all o the polar coordinates that are aliases or 0r2 91 be e$pressed as-
Chapter 7 )otes
!(
Chapter 7 )otes
!6
Chapter 7 )otes
!7
Chapter 7 )otes
!7
/ )itMPic'y Jbservation
Pic'y readers may notice that %hile this code ensures that 9 is in ran#e C? D 9 D ? radians2 it does not e$plicitly avoid the case %here 9 F C?. The value ? cannot be represented e$actly in loatin# point. In act2 because ? is irrational2 it can never be represented e$actly %ith any inite number o di#its in any baseN The value o the constant PI in our code is not e$actly eGual to ?2 it4s the closest number to ? that can be represented by a float. While double precision arithmetic is closer2 its not e$act. So2 you can thin' o this unction as returnin# a value rom C? to ?2 excl sive.
Chapter 7 )otes
!:
Chapter 7 )otes
!<
Solve or 9
Computin# r %as pretty easy. )o% solve or 9-
Chapter 7 )otes
"!
Pause or Thou#ht
There are t%o problems %ith this approach. The irst is that i x F =2 then the division is unde ined. The second is that arctan has a ran#e rom C<=> to 3<=>. The basic problem is that the division yOx e ectively discards some use ul in ormation %hen x F y. 8oth x and y can either be positive or ne#ative2 resultin# in our di erent possibilities2 correspondin# to the our di erent Guadrants that may contain the point. 8ut the division yOx results in a sin#le value. I %e ne#ate both x and y2 %e move to a di erent Guadrant in the plane2 but the ratio xOy doesn4t chan#e. 8ecause o these problems2 the complete eGuation or conversion rom Cartesian to polar coordinates reGuires some if statements to handle each Guadrant2 and is a bit o a mess or math people.
Chapter 7 )otes &D *ath Primer or +raphics , +ame Dev ""
atan"
Puc'ily2 pro#rammers have the atan2 unction2 %hich properly computes the an#le or all x and y e$cept or the pes'y case at the ori#in. 8orro%in# this notation2 let4s de ine an atan" unction %e can use in these notes in our math notation.
Chapter 7 )otes
"&
atan"
Chapter 7 )otes
"(
Chapter 7 )otes
"6
Computin# 9
8ac' to the tas' at hand- computin# the polar an#le 9 rom a set o "D Cartesian coordinates. /rmed %ith the atan" unction2 %e can easily convert "D Cartesian coordinates to polar orm.
Chapter 7 )otes
"7
Code Snippet
Chapter 7 )otes
"7
Section 7."-
Chapter 7 )otes
":
Chapter 7 )otes
"<
Section 7.&-
Chapter 7 )otes
&=
Chapter 7 )otes
&!
Chapter 7 )otes
&&
Chapter 7 )otes
&6
Chapter 7 )otes
&7
Chapter 7 )otes
&7
Chapter 7 )otes
&:
Irritatin# Disadvanta#e !
The de ault horiUontal direction at 9 F = points in the direction o 3x. This is un ortunate2 since or us2 3x points Hto the ri#htI or Heast2I neither o %hich are the de ault directions in most people4s mind. Similar to the %ay that numbers on a cloc' start at the top2 it %ould be nicer or us i the horiUontal polar a$is pointed to%ards 3#2 %hich is H or%ardI or Hnorth.I
Chapter 7 )otes &D *ath Primer or +raphics , +ame Dev &<
Chapter 7 )otes
(&
Chapter 7 )otes
((
Chapter 7 )otes
(6
Chapter 7 )otes
(7
Chapter 7 )otes
(7
Chapter 7 )otes
(:
/ sin#ularity occurs %hen the pitch an#le is set to <=> 0or any alias o these values1.
In this situation2 'no%n as +imbal loc'2 the direction indicated is purely vertical 0strai#ht up or strai#ht do%n12 and the headin# an#le is irrelevant. We4ll have a #reat deal more to say about +imbal loc' %hen %e discuss ;uler an#les in Chapter :.
Chapter 7 )otes
(<
Chapter 7 )otes
6=
Chapter 7 )otes
6!
Chapter 7 )otes
6"
Chapter 7 )otes
6&
Chapter 7 )otes
6(
Chapter 7 )otes
66
Pet4s see i %e can convert spherical coordinates to &D Cartesian coordinates. For no%2 our discussion %ill use the traditional ri#htM handed conventions or both Cartesian and spherical spaces. Pater %e4ll sho% conversions applicable to our le tM handed conventions. ;$amine the i#ure on the ne$t slide2 %hich sho%s both spherical and Cartesian coordinates.
Chapter 7 )otes &D *ath Primer or +raphics , +ame Dev 67
Chapter 7 )otes
67
What is dB
)otice that %e4ve introduced a ne% variable d2 the horiUontal distance bet%een the point and the vertical a$is.
Chapter 7 )otes
6:
Computin# #
From the ri#ht trian#le %ith hypotenuse r and le#s d and #2 %e see that #Or F cos V2 that is2 # F r cos V.
Chapter 7 )otes
6<
Computin# x and y
Consider that i V F <=>2 %e basically have "D polar coordinates. Pet x' and y' stand or the x and y coordinates that %ould result i V F <=>. /s in "D2 x' F r cos 92 y' F r sin 9. )otice that %hen V F <=>2 d F r. /s V decreases2 d decreases2 and by similar trian#les xOx' F yOy' F dOr. Poo'in# at trian#le d#r a#ain2 %e observe that dOr F sin V.
Chapter 7 )otes
7=
Continuin#
r is easy /s be ore2 the sin#ularity at the ori#in %hen r F = is handled as a special case. The headin# an#le is surprisin#ly simple to compute usin# our atan" unction2 h F atan"0x2 #1. This tric' %or's because atan" only uses the ratio o its ar#uments and their si#ns. ;$amine the eGuations x F r cos p sin h( y F Cr sin p( and # F r cos p cos h and notice that the scale actor o r cos p is common to both x and #. Furthermore2 by usin# canonical coordinates %e are assumin# r L = and C <=> D p D <=>2 thus cos p [ = and the common scale actor is al%ays nonne#ative.
Chapter 7 )otes &D *ath Primer or +raphics , +ame Dev 7"
Finally
Finally2 once %e 'no% r2 %e can solve or p rom y. y F Cr sin p CyOr F sin p p F arcsin0CyOr1 The arcsin unction has a ran#e o C<=> to <=>2 %hich ortunately coincides %ith the ran#e or p %ithin the canonical set.
Chapter 7 )otes &D *ath Primer or +raphics , +ame Dev 7&
Chapter 7 )otes
7(
Section 7.(-
Chapter 7 )otes
76
Chapter 7 )otes
77
Chapter 7 )otes
77