# Method default argument whose type is the class not yet defined

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Nov 12 05:46:27 CET 2012

On Mon, 12 Nov 2012 00:31:53 +0000, Oscar Benjamin wrote:

[...]
>>> You were right the first time, Chris. A point that happens to coincide
>>> with the arbitrarily chosen origin is no more truthy or falsey than
>>> any other. A vector of length 0 on the other hand is a very different
>>> beast.
>>
>> Nonsense. The length and direction of a vector is relative to the
>> origin. If the origin is arbitrary, as you claim, then so is the length
>> of the vector.
>
> Wrong on all counts. Neither the length not the direction os a vector
> are relative to any origin. When we choose to express a vector in
> Cartesian components our representation assumes an orientation for the
> axes of the coordinate system. Even in this sense, though, the origin
> itself does not affect the components of the vector.

Draw a set of axes and mark the vector [1, 1]. Here's a crappy ASCII art
diagram, with X marking the head of the vector and a line drawn from the

|
|   X
|  /
| /
|/
+------

Now draw a second set of axes with the origin set at the head of that
vector. For reference, I leave the previous axis in place. As before, X
represents the head of the vector.

|   |
----X-----
|   |
|   |
|   |
+---|--

Note that the "body" of the vector -- the line from the origin to the
head -- is gone. That's because the vector [1, 1] is transformed to the
vector [0, 0] under a translation of one unit in both the X and Y
directions. The magnitude of the vector under one coordinate system is 1,
under the second it is 0.

In a nutshell, you can't talk about either *distance* (magnitude) or
*direction* without an answer to "distance from where? direction relative
to what?".

> I have spent a fair few hours in the past few weeks persuading teenaged
> Engineering students to maintain a clear distinction between points,
> vectors and lines. One of the ways that I distinguish vectors from
> points is to say that a vector is like an arrow but its base has no
> particular position. A point on the other hand is quite simply a
> position. Given an origin (an arbitrarily chosen point) we can specify
> another point using a "position vector": a vector from the origin to the
> point in question.

Just because you have spent a lot of time and effort giving people advice

[...]
> Wrong. The point (0,0,0,...) in some ND space is an arbitrarily chosen
> position. By this I don't mean to say that the sequence of coordinates
> consisting of all zeros is arbitrary. The choice of the point *in the
> real/hypothetical space* that is designated by the sequence of zero
> coordinates is arbitrary.

So what? All you are saying is that there is more than one coordinate
system, and we can choose the one we like for any problem. Of course we
can, and that's a good thing.

>>> The significance of zero in real algebra is not that it is the origin
>>> but rather that it is the additive and multiplicative zero:
>>>
>>>    a + 0 = a  for any real number a
>>>    a * 0 = 0 for any real number a
>>
>> I'm not sure what you mean by "additive and multiplicative zero", you
>> appear to be conflating two different properties here. 0 is the
>> additive *identity*, but 1 is the multiplicative identity:
>
> I mean that it has the properties that zero has when used in addition
> and multiplication:
> http://en.wikipedia.org/wiki/0_%28number%29#Elementary_algebra

I see no reference to "additive and multiplicative zero" there. Did you
make up that terminology? The *identity* element is a common mathematical
term, but 1 is the multiplicative identity element.

What you are describing is generally known as the "absorbing element"
over multiplication: if X*a = X for any a, then X is an absorbing element
under multiplication.

http://en.wikipedia.org/wiki/Absorbing_element

And by the way, the vector [0, 0] (generalised to however many dimensions
you need) is not necessarily the only null (zero) vector. Some vector
spaces have many null vectors with non-zero components.

http://en.wikipedia.org/wiki/Zero_vector

but I digress.

The exact terminology doesn't really change anything, since everything
you say about vector [0,0] applies equally to the point (0,0) in the
Cartesian plane.

[...]
>>> There is however no meaningful sense in which points (as opposed to
>>> vectors) can be added to each other or multiplied by anything, so
>>> there is no zero point.
>>
>> I think that the great mathematician Carl Gauss would have something to
>
> Is the text below a quote?

No.

>> Points in the plane are equivalent to complex numbers, and you can
>> equivalent to a translation; multiplication of a scalar with a point is
>> equivalent to a scale transformation. Multiplying two points is
>> equivalent to complex multiplication, which is a scale + a rotation.
>
> The last point is bizarre. Complex multiplication makes no sense when
> you're trying to think about vectors. Draw a 2D plot and convince
> yourself that the square of the point (0, 1) is (-1, 0).

Um, yes? It's a rotation of the point (0, 1) by 90° counter-clockwise,
with a scale factor of 1. Does that confuse you? It's a straight-forward
geometric interpretation of multiplication in the complex plane.

http://www.clarku.edu/~djoyce/complex/mult.html

If you take the vector [0, 1] and rotate it by 90° counter-clockwise, you
get the vector [-1, 0].

>> Oh look, that's exactly the same geometric interpretation as for
>> vectors. Hardly surprising, since vectors are the magnitude and
>> direction of a line from the origin to a point.
>
> Here it becomes clear that you have conflated "position vectors" with
> vectors in general. Let me list some other examples of vectors that are
> clearly not "from the origin to a point":
>
> velocity
> acceleration
> force
> electric field
> angular momentum
> wave vector
>
> (I could go on)

But they are, all of them, without exception. E.g. velocity is relative
to some frame of reference, that is, which sets the "zero velocity"
relative to which all other velocities are measured. Electric fields are
relative to the vacuum far from any electric charges. And so on.

I quote:

"The angular momentum L of a particle about a given origin is defined as:

L = r × p

where r is the position vector of the particle relative to the origin, p
is the linear momentum of the particle, and × denotes the cross product."

http://en.wikipedia.org/wiki/Angular_momentum

Is there some part of "about a given origin" which needs additional
explanation?

--
Steven