Re: 3d Vector Types and operators
| От | Sam Mason |
|---|---|
| Тема | Re: 3d Vector Types and operators |
| Дата | |
| Msg-id | 20091014171430.GS5407@samason.me.uk обсуждение |
| Ответ на | 3d Vector Types and operators (Andrew Bailey <hazlorealidad@gmail.com>) |
| Список | pgsql-general |
On Wed, Oct 14, 2009 at 12:04:26PM -0500, Andrew Bailey wrote:
> I cant find in the documentation support for a 3 dimensional vector,
> I have only seen the array type, I am interested in doing vector dot
> products and vector cross products, also summing vectors and
> multiplying by a scalar quantity
If you did do this, I'd be tempted to use something like:
create type point3d AS (
x float8, y float8, z float8
);
and then write your functions using this. The length of an array isn't
part of its type and so PG wouldn't be able to stop you from writing:
select array[1,2,3] + array[2,3,4,5,6];
if you provided the appropriate operators. If you use a fixed sized
tuple, as above, you'd get errors if you tried to use points of the
wrong dimensionality.
--
Sam http://samason.me.uk/
В списке pgsql-general по дате отправления: