From: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: 3d Vector Types and operators |
Date: | 2009-10-14 17:14:30 |
Message-ID: | 20091014171430.GS5407@samason.me.uk |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | 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/
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Bailey | 2009-10-14 17:17:14 | Re: How ad an increasing index to a query result? |
Previous Message | Josip | 2009-10-14 17:05:52 | How ad an increasing index to a query result? |