Affine transforms - matrix algebra
pavel.safrata at oracle.com
Mon Aug 13 11:13:35 PDT 2012
On 13.8.2012 19:52, Pedro Duque Vieira wrote:
> Hi Pedro,
> looks like we are condemned to stick to our existing precedents..
> pity :(
> On 13.8.2012 18:26, Pedro Duque Vieira wrote:
> // Creates a point with distances from origin added (adds two
> public Point3D subtract(Point3D point)
> // Creates a point with the given point's distances from
> // (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..
> // 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?
> You're already doing things that make no sense for a Point3D, like
> adding two points, so it's pretty obvious that this is being used to
> represent Points and Vectors so this shouldn't be hidden from the user
> to prevent further confusion.
> I think this should really also be stated on the javadoc of Point3D.
Yes, it will be stated. I'm just not sure why 'magnitude' is better then
>> Hi Pavel,
>> public Point3D add(Point3D point)
>> public double getLength()
> Your missing:
> - getAngle()
> // gets the angle of the vector
> Angle from what?
> A Vector has an angle (or direction) it's normally from the the right
> side of the horizontal axis (the vertical axis splits the horizontal
> axis into right and left side).
We are in 3D - we have X, Y and Z axes. Which one is "the horizontal"? I
don't think this is a clear API, you can use point.angle(X_AXIS) if you
> - 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..
> Again, you are using Point as a vector although without separating
> them into distinct classes and you should distinguish the two. It
> makes no sense to add two points, make the cross product, etc.
We are using one class for them just because we cannot distinguish them.
If we added such flag, what would be the default value? The existing
applications use Point3D both as point and as vector, so some of the
usages would always become invalid. So again, because of the backward
compatibility we need to represent point and vector by the same thing.
>> 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.
> Yes your right, it does come in handy for some computer graphics
> operations though.
> Thanks again,
> Pedro Duque Vieira
More information about the openjfx-dev