Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 13, 2012 Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Does D have a math library that defines, points, vectors and matrices including the appropriate functions(addition, dot product, cross product, etc)? I'm starting my next game and I would like to know what my options are. I plan on using SDL, I'm not exactly into OpenGL yet, since I'm new and I only wish to work in 2D. Nonetheless, I would prefer to get acquainted with using linear algebra formally in games before I move to 3D. |
March 13, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Pons | On Tue, Mar 13, 2012 at 08:25:49PM +0100, Chris Pons wrote: > Does D have a math library that defines, points, vectors and matrices including the appropriate functions(addition, dot product, cross product, etc)? I'd like to know too. I have a medium-sized D project in the works, but right now I'm stuck at deciding how best to represent matrices and vectors in a generic way. My usage will be significantly different from game programming, though, 'cos I'll be dealing with arbitrary-dimensioned vectors and matrices, not just your typical 2D/3D vector (or 4D homogenous). But it'd be nice if both can be handled generically without crippling performance losses in the 2D/3D case for game dev. T -- Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. -- Carl B. Constantine |
March 13, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On 14.03.2012 0:03, H. S. Teoh wrote: > On Tue, Mar 13, 2012 at 08:25:49PM +0100, Chris Pons wrote: >> Does D have a math library that defines, points, vectors and >> matrices including the appropriate functions(addition, dot product, >> cross product, etc)? > > I'd like to know too. > > I have a medium-sized D project in the works, but right now I'm stuck at > deciding how best to represent matrices and vectors in a generic way. My > usage will be significantly different from game programming, though, > 'cos I'll be dealing with arbitrary-dimensioned vectors and matrices, > not just your typical 2D/3D vector (or 4D homogenous). > > But it'd be nice if both can be handled generically without crippling > performance losses in the 2D/3D case for game dev. > > > T > SciD worths a look, though never used nor had the need to: https://github.com/kyllingstad/scid -- Dmitry Olshansky |
March 13, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | Thanks, I'll take a look. I'm new, so I might need some help properly building this. I will post back if I have any problems.
On Tuesday, 13 March 2012 at 20:06:13 UTC, Dmitry Olshansky wrote:
> On 14.03.2012 0:03, H. S. Teoh wrote:
>> On Tue, Mar 13, 2012 at 08:25:49PM +0100, Chris Pons wrote:
>>> Does D have a math library that defines, points, vectors and
>>> matrices including the appropriate functions(addition, dot product,
>>> cross product, etc)?
>>
>> I'd like to know too.
>>
>> I have a medium-sized D project in the works, but right now I'm stuck at
>> deciding how best to represent matrices and vectors in a generic way. My
>> usage will be significantly different from game programming, though,
>> 'cos I'll be dealing with arbitrary-dimensioned vectors and matrices,
>> not just your typical 2D/3D vector (or 4D homogenous).
>>
>> But it'd be nice if both can be handled generically without crippling
>> performance losses in the 2D/3D case for game dev.
>>
>>
>> T
>>
>
> SciD worths a look, though never used nor had the need to:
> https://github.com/kyllingstad/scid
|
March 13, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | On 03/13/2012 09:06 PM, Dmitry Olshansky wrote: > On 14.03.2012 0:03, H. S. Teoh wrote: >> On Tue, Mar 13, 2012 at 08:25:49PM +0100, Chris Pons wrote: >>> Does D have a math library that defines, points, vectors and >>> matrices including the appropriate functions(addition, dot product, >>> cross product, etc)? >> >> I'd like to know too. >> >> I have a medium-sized D project in the works, but right now I'm stuck at >> deciding how best to represent matrices and vectors in a generic way. My struct CMatrix(T) //CMatrix { T [] data; size_t rows; size_t cols; size_t rowStep; Stride(T) row() { } T [] rowArray() { } //no colArray } struct LMatrix(T) //Lapack Matrix { T [] data; size_t rows; size_t cols; size_t colStep; } Above are "storage types" of the matrix. They can be rectangular or triangular. I'd move the "matrix shape" to the operation. Because most of the time you already know the shape. aadd_upperTriangular_upperTraingular( result, a, b); So the operation for the upperTriangular "shape" can be applied to the generic rectangular "storage" type. I know nobody likes the underscore syntax but I can't come up with anything else. Also separate the Lapack Matrix from the conventional CMatrix in other modules. I'd stick to conventional routines for adding subtracting and not the build in binary operators like +. ----- In scid the colStep or leading address of a is an alias. I think this should not be so. >> usage will be significantly different from game programming, though, >> 'cos I'll be dealing with arbitrary-dimensioned vectors and matrices, >> not just your typical 2D/3D vector (or 4D homogenous). >> >> But it'd be nice if both can be handled generically without crippling >> performance losses in the 2D/3D case for game dev. >> >> >> T >> > > SciD worths a look, though never used nor had the need to: > https://github.com/kyllingstad/scid > |
March 13, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Pons | SciD is a scientific math library providing vectors/matrices of arbitrary sizes, but not useful at all for game development. See gl3n for a game-oriented vector/matrix library: https://bitbucket.org/dav1d/gl3n Also, AFAIK, Manu is working on what should end up being a Phobos module for game-oriented matrices/vectors. |
March 13, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to sclytrack | On 03/13/2012 09:30 PM, sclytrack wrote:
> On 03/13/2012 09:06 PM, Dmitry Olshansky wrote:
>> On 14.03.2012 0:03, H. S. Teoh wrote:
>>> On Tue, Mar 13, 2012 at 08:25:49PM +0100, Chris Pons wrote:
>>>> Does D have a math library that defines, points, vectors and
>>>> matrices including the appropriate functions(addition, dot product,
>>>> cross product, etc)?
>>>
>>> I'd like to know too.
>>>
>>> I have a medium-sized D project in the works, but right now I'm stuck at
>>> deciding how best to represent matrices and vectors in a generic way. My
>
For vectors I'd propose
struct Stride(T)
{
T [] data;
size_t step;
}
For fixed size vectors, just use "float [3] v;"
I'd only use below if you can force it into phobos. If not use above.
struct Vec3(T)
{
T x;
T y;
T z;
}
|
March 13, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to sclytrack |
> Stride(T) row()
> {
> }
>
Stride!(T) row()
{
}
|
March 13, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Pons | SciD looks nice, but it seems to be a bit too complicated for my use. Are there any other alternatives?
On Tuesday, 13 March 2012 at 20:14:14 UTC, Chris Pons wrote:
> Thanks, I'll take a look. I'm new, so I might need some help properly building this. I will post back if I have any problems.
>
> On Tuesday, 13 March 2012 at 20:06:13 UTC, Dmitry Olshansky wrote:
>> On 14.03.2012 0:03, H. S. Teoh wrote:
>>> On Tue, Mar 13, 2012 at 08:25:49PM +0100, Chris Pons wrote:
>>>> Does D have a math library that defines, points, vectors and
>>>> matrices including the appropriate functions(addition, dot product,
>>>> cross product, etc)?
>>>
>>> I'd like to know too.
>>>
>>> I have a medium-sized D project in the works, but right now I'm stuck at
>>> deciding how best to represent matrices and vectors in a generic way. My
>>> usage will be significantly different from game programming, though,
>>> 'cos I'll be dealing with arbitrary-dimensioned vectors and matrices,
>>> not just your typical 2D/3D vector (or 4D homogenous).
>>>
>>> But it'd be nice if both can be handled generically without crippling
>>> performance losses in the 2D/3D case for game dev.
>>>
>>>
>>> T
>>>
>>
>> SciD worths a look, though never used nor had the need to:
>> https://github.com/kyllingstad/scid
|
March 14, 2012 Re: Math Libraries (and vectors, matrices, etc) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kiith-Sa | Oops, I didn't see the replies, after my last message. I'll check this out. Thanks!
On Tuesday, 13 March 2012 at 20:34:54 UTC, Kiith-Sa wrote:
> SciD is a scientific math library providing vectors/matrices of arbitrary
> sizes, but not useful at all for game development.
>
> See gl3n for a game-oriented vector/matrix library:
> https://bitbucket.org/dav1d/gl3n
>
> Also, AFAIK, Manu is working on what should end up being
> a Phobos module for game-oriented matrices/vectors.
|
Copyright © 1999-2021 by the D Language Foundation