Search Postgresql Archives

Re: 3d Vector Types and operators

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux