Guest User

Processing 3d vector

a guest
Nov 28th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import toxi.geom.*;
  2. //https://bitbucket.org/postspectacular/toxiclibs/downloads/
  3. //http://toxiclibs.org/docs/core/toxi/geom/Vec3D.html
  4. Vec3D vec1 =new Vec3D(100,200,0);
  5. Vec3D vec2 =new Vec3D(-100,50,0);
  6.  
  7. void setup(){
  8. size(600,600);
  9. }
  10. void draw(){
  11. background(0);
  12. translate(300,300);
  13. stroke(100);
  14. strokeWeight(0.2);
  15. line(-600,0,600,0);
  16. line(0,-600,0,600);
  17. stroke(255,0,0);
  18. strokeWeight(6);
  19. point(vec1.x,vec1.y);
  20. strokeWeight(2);
  21. line(0,0,vec1.x,vec1.y);
  22. stroke(0,255,0);
  23. strokeWeight(6);
  24. point(vec2.x,vec2.y);
  25. strokeWeight(2);
  26. line(0,0,vec1.x,vec1.y);
  27. Vec3D newVec = vec1.copy();
  28. newVec.normalize();
  29. newVec.scaleSelf(100);
  30. newVec = vec2.sub(vec1);
  31. stroke(200);
  32. strokeWeight(6);
  33. point(newVec.x,newVec.y);
  34. strokeWeight(2);
  35. line(0,0,newVec.x,newVec.y);
  36. line(0,0,-vec1.x,-vec1.y);
  37. line(-vec1.x,-vec1.y,newVec.x,newVec.y);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment