Math Libraries (and vectors, matrices, etc)

sclytrack sclytrack at hotmail.com
Tue Mar 13 13:40:18 PDT 2012


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;
}



More information about the Digitalmars-d-learn mailing list