Affine transforms - matrix algebra

Pavel Safrata pavel.safrata at oracle.com
Mon Aug 13 10:05:48 PDT 2012


Hi Pedro,
looks like we are condemned to stick to our existing precedents..

On 13.8.2012 18:26, Pedro Duque Vieira wrote:
> Hi Pavel,
>
>        public Point3D add(Point3D point)
>            // Creates a point with distances from origin added (adds two
>     vectors)
>        public Point3D subtract(Point3D point)
>            // Creates a point with the given point's distances from origin
>     subtracted
>            // (subtracts two vectors)
>        public Point3D normalize()
>            // Gets a point in the same direction from the origin with
>     distance from the origin equal to one
>            // (normalizes a vector)
>      ? should the above three methods be named getSomething to stress that
>     the operation doesn't modify the object? 
>
>
> Yes, I think it's better to call them getSomething.

As I wrote in my other email, we already have distance(Point3D), so to 
be consistent we should rather strip the 'get' everywhere..

>
>      public double getLength()
>            // Gets distance from the origin (lenght of a vector)
>
> I'd prefer getMagnitude(), this way it's obvious your getting the 
> lenght of a vector

I'm not sure, magnitude of a point is similar nonsense to length of a 
point and I guess users would search for the word "length" first. Does 
anyone else have an opinion on this?

>
> Your missing:
> - getAngle()
> // gets the angle of the vector

Angle from what?

> - getType
> // returns whether this represents a vector or a point

If we wanted to distinguish vector from point, we would introduce 
Vector3D class. But we have the Rotate class that is already used with 
Point3D representing a vector and it has no such flag..

>
> Your missing on matrix or affine:
> - transpose()
> // transposes the matrix

I don't think we can add this because the resulting transform would 
generally not be affine.

Thanks,
Pavel

>
> Thanks, best regards,
> -- 
> Pedro Duque Vieira




More information about the openjfx-dev mailing list