You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below you will find the last example in the reference area of the website for the p5.Vector.dist() method.
You'll notice the method isn't actually used in the example. I figure either:
A. The intention was to include a console log of p5.Vector.dist(v1, v3) to show that it was equal to the purple magnitude vector (as they should be). Both are 36 if you do the math.
or
B. There's no problem and the example intentionally left out the dist method in the example, showing instead the mag() method so the user could work out on their own that they should be the same?
functionsetup(){createCanvas(100,100);describe('Three arrows drawn on a gray square. A red and a blue arrow extend from the top left. A purple arrow extends from the tip of the red arrow to the tip of the blue arrow. The number 36 is written in black near the purple arrow.');}functiondraw(){background(200);letorigin=createVector(0,0);// Draw the red arrow.letv1=createVector(50,50);drawArrow(origin,v1,'red');// Draw the blue arrow.letv2=createVector(20,70);drawArrow(origin,v2,'blue');// Purple arrow.letv3=p5.Vector.sub(v2,v1);drawArrow(v1,v3,'purple');// Style the text.textAlign(CENTER);// Display the magnitude.letm=floor(v3.mag());text(m,50,75);}// Draws an arrow between two vectors.functiondrawArrow(base,vec,myColor){push();stroke(myColor);strokeWeight(3);fill(myColor);translate(base.x,base.y);line(0,0,vec.x,vec.y);rotate(vec.heading());letarrowSize=7;translate(vec.mag()-arrowSize,0);triangle(0,arrowSize/2,0,-arrowSize/2,arrowSize,0);pop();}
The text was updated successfully, but these errors were encountered:
Below you will find the last example in the reference area of the website for the
p5.Vector.dist()
method.You'll notice the method isn't actually used in the example. I figure either:
A. The intention was to include a console log of
p5.Vector.dist(v1, v3)
to show that it was equal to the purple magnitude vector (as they should be). Both are36
if you do the math.or
B. There's no problem and the example intentionally left out the dist method in the example, showing instead the mag() method so the user could work out on their own that they should be the same?
The text was updated successfully, but these errors were encountered: