Using villares PVector (python implementation) in py5

@hx2A If you create a Vec2D class (along lines of @villares PVector) and add a method:-

def to_array(self):
        return [self.x, self.y]

Then the following works just dandy:-

py5.vertices([v.to_array() for v in morph])

Which as you say avoids looping through morph…

If you just add to_array method to PVector then you get the following error

vertex() with x, y, and z coordinates can only be used with a renderer that supports 3D, such as P3D. Use a version without a z-coordinate instead.

Another strong argument for a separate Vec2D class, along with cross product error (returns vector instead of scalar) etc etc.

1 Like