Skip to content
This repository has been archived by the owner on Jun 25, 2019. It is now read-only.

Commit

Permalink
It has been decreed. heading2D() is now heading()
Browse files Browse the repository at this point in the history
  • Loading branch information
shiffman committed Dec 6, 2012
1 parent 7003e6e commit a6d500a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions raw/chapters/01_vectors.asc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ Addition was really just the first step. There are many mathematical operation
((("cross() function (PVector class)")))
((("dist() function (PVector class)")))
((("dot() function (PVector class)")))
((("heading2D() function (PVector class)")))
((("heading() function (PVector class)")))
((("lerp() function (PVector class)")))
((("limit() function (PVector class)")))
((("PVector class (Processing)","function list for")))
Expand All @@ -431,7 +431,7 @@ Addition was really just the first step. There are many mathematical operation
- [function]*setMag()* - set the magnitude of a vector
- [function]*normalize()* — normalize the vector to a unit length of 1
- [function]*limit()* — limit the magnitude of a vector
- [function]*heading2D()* — the heading of a vector expressed as an angle
- [function]*heading()* — the 2D heading of a vector expressed as an angle
- [function]*rotate()* — rotate a 2D vector by an angle
- [function]*lerp()* — linear interpolate to another vector
- [function]*dist()* — the Euclidean distance between two vectors (considered as points)
Expand Down
12 changes: 6 additions & 6 deletions raw/chapters/03_oscillation.asc
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,17 @@ image::imgs/chapter03/ch03_ex03.png[canvas="processingjs/chapter03/_3_03_pointin
}
----

((("heading2D() function (PVector class)")))
((("motion","heading2D() function (PVector class)")))
((("PVector class (Processing)","heading2D() function")))
((("tangent","heading2D() function (PVector class)")))
((("heading() function (PVector class)")))
((("motion","heading() function (PVector class)")))
((("PVector class (Processing)","heading() function")))
((("tangent","heading() function (PVector class)")))

To simplify this even further, the [klass]*PVector* class itself provides a function called [klass]*heading2D()*, which takes care of calling [function]*atan2()* for you so you can get the direction angle, in radians, for any Processing [klass]*PVector*.
To simplify this even further, the [klass]*PVector* class itself provides a function called [klass]*heading()*, which takes care of calling [function]*atan2()* for you so you can get the 2D direction angle, in radians, for any Processing [klass]*PVector*.

[source,java]
----
// The easiest way to do this!
float angle = velocity.heading2D();
float angle = velocity.heading();
----

[[chapter03_exercise3]]
Expand Down
2 changes: 1 addition & 1 deletion raw/chapters/06_steering.asc
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class Vehicle {
// Vehicle is a triangle pointing in
// the direction of velocity; since it is drawn
// pointing up, we rotate it an additional 90 degrees.
float theta = velocity.heading2D() + PI/2;
float theta = velocity.heading() + PI/2;
fill(175);
stroke(0);
pushMatrix();
Expand Down

0 comments on commit a6d500a

Please sign in to comment.