How to link an sphere to a vector

edited November 2015 in Library Questions

Hey guys,

I'm pretty new at coding and at processing so my question is a very basic one. I'm working on an algorithm to simulate the behaviour of microalgae unicellular reproduction. So first of all if you guys have any reference to show me I'd be very gratefull.

But the main question is, how do I link an sphere to a 3D vector like the ones from ToxicLibs so I can do the sphere move and interact with the others by the vector maths??

Thank you very much,

Best regards,

Answers

  • Just use the contents of the vector as the sphere coordinates. Using Processing's own PVector would be something like tis:

    pseudo

    PVector pos = new PVector(mouseX, mouseY, 100);
    pushMatrix();
    translate(pos.x, pos.y, pos.z);
    sphere(10);
    popMatrix()
    
  • Wouldn't it be better to use point() instead of sphere for large amounts of vectors?

  • yes

    or use sphere() with lights() (slows things down even more) and noStroke() and reduced sphereDetail....

Sign In or Register to comment.