what do the operator * exactly ?
what do the operator * exactly ?
От:
molinet <molinet@ibp.u-psud.fr>
Дата:
Does somebody can explain me what the operators * and / do exactly? for example select '(1,1)'::point * '(2,2)':: point ; gives (0,4) select '(1,1)'::point * '(3,3)'::point ; gives (0,6) and what does the / operator ? thanks for your response MOLINET S.
Re: what do the operator * exactly ?
От:
Martijn van Oosterhout <kleptog@svana.org>
Дата:
On Wed, May 29, 2002 at 03:48:22PM +0200, molinet wrote: > Does somebody can explain me what the operators * and / do exactly? > for example > select '(1,1)'::point * '(2,2)':: point ; > gives > (0,4) Well, i imagine it's treating them like complex numbers and multiplying them giving a rotation/scale conbination. (1 + 1i) * (2 + 2i) = (0 + 4i) > select '(1,1)'::point * '(3,3)'::point ; > gives > (0,6) (1 + 1i) * (3 + 3i) = (0 + 6i) > and what does the / operator ? > thanks for your response Does a division probably. It's a bit tricky analytically but if you imagine that the point (2,2) means to scale by 2*sqrt(2) (the distance from (0,0)) and to rotate by 45 degrees (the angle between the X-axis and the line joining (0,0) and (2,2)) you're getting there. HTH, -- Martijn van Oosterhout http://svana.org/kleptog/ > Canada, Mexico, and Australia form the Axis of Nations That > Are Actually Quite Nice But Secretly Have Nasty Thoughts About America
Re: what do the operator * exactly ?
От:
Thomas Lockhart <lockhart@fourpalms.org>
Дата:
> Does somebody can explain me what the operators * and / do exactly?
Scaling and rotation. Addition/subtraction does translation.
> for example
> select '(1,1)'::point * '(2,2)':: point ;
> gives
> (0,4)
This is analogous to complex arithmetic, where there are two orthogonal
dimensions. If you multiply '(1,1)'::point by '(2,0)'::point, then it
appears to be simple scaling. If you multiply by '(0,1)'::point instead,
then it is a rotation, flipping the input about the X axis.
hth
- Thomas