Why can't we pass PVector to translate?

I’ve just started using P3D and while translating a cube I wonder that why can’t we pass a variable of type PVector to translate method. I think that functionality wise it should work. Correct me if I am wrong.

4 Likes

This is something I’ve often wondered as well. If you’re tired of writing out all the x, y and z variables I’d make a custom class that looks like this

void Translate(PVector p){
  translate(p.x,p.y,p.z);
}
void Translate2(PVector p, PShape s){
  s.translate(p.x,p.y,p.z);
}

Although there may be some specific cases where this won’t work, possibly inside of the beginShape() function.

4 Likes

Don’t use a capital for a method name, it’s against conventions.
Also you can just name it translate, function overloading will take care of it. That is, because you call it with a PVector for example it will know that it needs to call translate that accepts as PVector as a argument.

6 Likes

It´s not too hard to build your own Transformation-Class that passes your Rotations or Translations through to P3D and takes Vektors or Vektors with Angles and so far from the using coder.

Yes i agree. Still i think that their should be an overridden translate method which can take PVector as a parameter, as main aim of Processing is to enable artists and non-coders to build what they imagine rather not to learn how to code before starting.

1 Like

I’m writing an orbit. Same problem.

you can use these functions