-
-
Notifications
You must be signed in to change notification settings - Fork 70
Implementation of PVector.setHeading() #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Created by: benfry Adding it for parity with p5.js… Here's the full implementation from there: _main.default.Vector.prototype.setHeading = function setHeading(a) {
var m = this.mag();
this.x = m * Math.cos(a);
this.y = m * Math.sin(a);
return this;
}; |
Created by: arijit4 public PVector setHeading(float angle) {
float m = mag();
x = m * Math.cos(a);
y = m * Math.sin(a);
return this;
} shouldn't it be the following? public PVector setHeading(float angle) {
float m = mag();
x = m * Math.cos(angle);
y = m * Math.sin(angle);
return this;
} |
Created by: benfry Yes, and it was immediately fixed in the next commit. |
Created by: arijit4 @benfry |
Created by: github-actions[bot] This issue has been automatically locked. To avoid confusion with reports that have already been resolved, closed issues are automatically locked 30 days after the last comment. Please open a new issue for related bugs. |
Created by: arijit4
There's an method named
PVector.setHeading()
inp5.Vector
class of p5.js to set the direction of an vector to any given angle. But there's no such option in Processing. It can be settled down easily. But the function seems more self explanatory and easy to understand. It also goes well with thePVector.heading()
method already present in Processing.An implementation might look like the following :
The text was updated successfully, but these errors were encountered: