Transform point using localToSceneTransform
Pavel Safrata
pavel.safrata at oracle.com
Wed Aug 1 08:55:06 PDT 2012
I agree with Martin. Subtracting a vector from a vector is again a
vector. If you need to convert a vector to a point, I believe you in
fact want an origin (point) shifted by a vector. So the operation will
look like what it really is - new Point().shift(vector). Similarly
converting a point to a vector is in fact creating vector out of two
points - constructor Vector(Point, Point) makes perfect sense and you
can than do simply new Vector(ORIGIN, your_point). Doesn't look bad
either. We may provide the static ORIGIN point (containing zeros) to
make those common operations easier.
Pavel
On 28.7.2012 0:19, Martin Desruisseaux wrote:
> Hello all
>
> Le 28/07/12 00:03, Kevin Rushforth a écrit :
>> Easy conversion between the Point and vector classes is important
>> even if you don't have a common base class. Otherwise developers have
>> to do a bunch of manual copying (or things like subtracting a 0
>> vector from a vector to convert it to a point).
>
> I think that omitting converters may be safer for a similar reason
> than omitting the Affine.setTranslate/setScale/setRotation methods: in
> many cases, users invoked Affine.setTranslate(...) in situations where
> they should really invoke Affine.translate(...); the fact that their
> original Affine was the identity transform may not be as universal as
> they though.
>
> I think this is similar for Point/Vector: I think that when a user
> converts a point to a vector, what he really wants is to get the
> distance relative to some origin. The origin may be (0,0,0) in 95% of
> cases, but not always (e.g. in map projections with "false easting"
> and "false northing"). Forcing a user to write "vector = point -
> origin" make his code more future-proof, by making more obvious where
> an origin is involved - even if it is (0,0,0) - and easier to adjust
> in case the origin moved.
>
> Martin
>
More information about the openjfx-dev
mailing list