• fullscreen
  • Vec2D_1_2.pde
  • // import the necessary toxiclibs libraries
    import toxi.geom.*; 
    import toxi.processing.*;
    // declare the vectors we will be using
    ToxiclibsSupport gfx;
    Vec2D m, n, p;
    void setup() {
      // initialise the ToxiclibsSupport class
      gfx=new ToxiclibsSupport(this);
      // create the three vectors
      m = new Vec2D(50,50); 
      n = new Vec2D(30,30);
      p = new Vec2D(10,10);
    void draw() {
      // translate so the centre of the screen is the origin
      for(int i=0;i<20;i++){
        // rotate each of the vectors a little, change these
        // to produce a variety of patterns
        // calculate the angle between m and n vectors and
        // use this to set the stroke colour
        float ang = m.angleBetween(n,true);
        // create a temporary vector for the final position of
        // the dot so we don't change our original vectors
        Vec2D blob = m.add(n);
        // draw a dot at the x,y co-ordinates of the sum of the
        // three vectors
        // we can now do this just by passing the Vec2D object
        // to the point command, easy!


    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.



    Report Sketch

    Report for inappropriate content

    Please provide details if possible:

    Your have successfully reported the sketch. Thank you very much for helping to keep OpenProcessing clean and tidy :)

    Make a Copyright Infringement claim

    Justin Pinkney

    Toxiclibs tutorials - Vec2D

    Add to Faves Me Likey@! 1
    You must login/register to add this sketch to your favorites.

    Writing some very basic tutorials for the Toxiclibs library.
    Part 1 Vec2D - http://www.cutsquash.com/2011/12/toxiclibs-tutorials-1-vec2d/

    Geo Meadows
    3 Dec 2011
    Thanks for taking the trouble to produce the tutorials, very interesting.
    hey Justin
    cool initiative. are you ok with adding these sketches here:
    http://www.openprocessing.org/classrooms/?classroomID=404 ?
    Justin Pinkney
    4 Dec 2011
    Hey thanks, I will be very happy if these tutorials end up being of any use to anyone else, and I will endeavour to add to the at least semi regularly.
    You need to login/register to comment.