Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import toxi.geom.*;
- //https://bitbucket.org/postspectacular/toxiclibs/downloads/
- //http://toxiclibs.org/docs/core/toxi/geom/Vec3D.html
- Vec3D vec1 =new Vec3D(100,200,0);
- Vec3D vec2 =new Vec3D(-100,50,0);
- void setup(){
- size(600,600);
- }
- void draw(){
- background(0);
- translate(300,300);
- stroke(100);
- strokeWeight(0.2);
- line(-600,0,600,0);
- line(0,-600,0,600);
- stroke(255,0,0);
- strokeWeight(6);
- point(vec1.x,vec1.y);
- strokeWeight(2);
- line(0,0,vec1.x,vec1.y);
- stroke(0,255,0);
- strokeWeight(6);
- point(vec2.x,vec2.y);
- strokeWeight(2);
- line(0,0,vec1.x,vec1.y);
- Vec3D newVec = vec1.copy();
- newVec.normalize();
- newVec.scaleSelf(100);
- newVec = vec2.sub(vec1);
- stroke(200);
- strokeWeight(6);
- point(newVec.x,newVec.y);
- strokeWeight(2);
- line(0,0,newVec.x,newVec.y);
- line(0,0,-vec1.x,-vec1.y);
- line(-vec1.x,-vec1.y,newVec.x,newVec.y);
- }
Advertisement
Add Comment
Please, Sign In to add comment