A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-November/150881.html below:

[Python-Dev] Second post: PEP 557, Data Classes

[Python-Dev] Second post: PEP 557, Data ClassesGreg Ewing greg.ewing at canterbury.ac.nz
Mon Nov 27 08:14:28 EST 2017
Chris Angelico wrote:
> I'm not sure there's any distinction between a "point" and a "vector
> from the origin to a point".

They transform differently. For example, translation affects
a point, but makes no difference to a vector.

There are two ways of dealing with that. One is to use vectors
to represent both and have two different operations, "transform
point" and "transform vector".

The other is to represent them using different types and have
one operation that does different things depending on the
type.

The advantage of the latter is that you can't accidentally
apply the wrong operation, e.g. transform_point on something
that's actually a vector.

(There's actually a third way -- use homogeneous coordinates
and represent points as (x, y, z, 1) and vectors as
(x, y, z, 0). But that's really a variation on the "different
types" idea.)

-- 
Greg
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4