www.digitalmars.com         C & C++   DMDScript  

D - geometric algebra as core component of D

reply "Sean L. Palmer" <seanpalmer earthlink.net> writes:
I think it would be fantastic Walter if you could read this webpage:

http://www.mrao.cam.ac.uk/~clifford/introduction/intro/intro.html

and then go back over the fundamental types and operations of D in much the
same way as you have extended it for complex numbers, and have D directly
support mathematical operations on multivectors using Clifford algebra.

I highly recommend anyone who has any interest in 3D math to read this page.
It generalizes the concept of rotation and vector products for all higher
dimensions by integrating the dot and cross product in much the same way
that complex numbers integrate real and imaginary parts.

This stuff is amazing... it's sad that mathematics had taken such a wrong
turn, but Clifford algebra (aka geometric algebra) attempts to correct the
problem.

They've got a C++ template library for multivectors, but D has no templates
so it wouldn't be easy to make this general in D from a user perspective.
It would have to go in the core language design.  (or, you can put in
generics  ;)

Sean
May 27 2002
next sibling parent Andy Walker <Andy_member pathlink.com> writes:
In article <acuc30$30hq$1 digitaldaemon.com>, Sean L. Palmer says...
I think it would be fantastic Walter if you could read this webpage:

http://www.mrao.cam.ac.uk/~clifford/introduction/intro/intro.html
This really ticks me off. I think about all the painful hours I spent trying to understand this stuff, and failing, and the real problem was that it was very badly described by the mathematics. Arrrrrgh. Let me say that again. Aaaaarrrrrrrrrrgh. I think it would be fantastic if there were a clear, powerful syntax for the Clifford algebra before Walter tries to implement it. Then graduate students in physics would would do it in Bright (D) or risk being ignored. That alone would be worth a pick-up load of masters theses in physics. It would also be one heck of a sales tool for Bright (D). It might guarantee that every Electrical Engineering graduate knows the language. Andy Walker jawalker stl.quik.com
May 27 2002
prev sibling next sibling parent "Robert Giuffre" <rgiuffre_No_Spam_ earthlink.net> writes:
My brain is going to explode after reading that article...
But hey, more power to the compiler...

;-}

Bob


"Sean L. Palmer" <seanpalmer earthlink.net> wrote in message
news:acuc30$30hq$1 digitaldaemon.com...
 I think it would be fantastic Walter if you could read this webpage:

 http://www.mrao.cam.ac.uk/~clifford/introduction/intro/intro.html

 and then go back over the fundamental types and operations of D in much
the
 same way as you have extended it for complex numbers, and have D directly
 support mathematical operations on multivectors using Clifford algebra.

 I highly recommend anyone who has any interest in 3D math to read this
page.
 It generalizes the concept of rotation and vector products for all higher
 dimensions by integrating the dot and cross product in much the same way
 that complex numbers integrate real and imaginary parts.

 This stuff is amazing... it's sad that mathematics had taken such a wrong
 turn, but Clifford algebra (aka geometric algebra) attempts to correct the
 problem.

 They've got a C++ template library for multivectors, but D has no
templates
 so it wouldn't be easy to make this general in D from a user perspective.
 It would have to go in the core language design.  (or, you can put in
 generics  ;)

 Sean
May 27 2002
prev sibling next sibling parent reply "Carlos" <carlos8294 msn.com> writes:
 and then go back over the fundamental types and operations of D in much
the
 same way as you have extended it for complex numbers, and have D directly
 support mathematical operations on multivectors using Clifford algebra.
I haven't read completely the article, but I don't think D should support that directly. Not that it wouldn't be good, but as far as I understand most of the programming languages (including C-like or C-based) are designed to be general purpose. If geometric algebra is ever included in any language, then that language would become (instantly or eventually) completely math oriented. Not that I wouldn't like that (I mean, Fortran is so old that I can't figure out how someone can still make NEW programs there, but it's still the best in math! --maybe that's why) but I'm not quite sure that this should be D's next step. Mainly because of one reason: if right now D (I mean, Walter) does that, then D would lose a big group (can't think of another word) of programmers: those who aren't interested in math. I know that programming is closely related to math, but not everything related to programming is math (obviously). For example, if D is better than C, and almost every operating system has been done in C, what stops us (D programmers) from doing a better OS in D. And if someone is writing an OS (not that I am), why would that someone need geometric algebra? It's like someone said before: by wanting that, you're wanting to add things that aren't really necessary, though they can be needed by some.
May 27 2002
next sibling parent "Sean L. Palmer" <seanpalmer earthlink.net> writes:
I suppose it can wait until D 2.0 when D supports generics or templates,
geometric algebra can be made into a module.

I was just thinking that if Walter went out of his way to support the
complex type, this kind of stuff isn't far beyond that.  Closer than you may
think.

With complex you can add a real to an imaginary to get a complex:

complex c = 2.0 + 3.0i;

With geometric algebra you can add a scalar and a vector and a bivector (etc
etc) to get a generic multidimensional vector:

multivector v = 3.0 + [ 1.0, 2.0, 0.5 ];

multiplication of vectors is defined to produce both a scalar and a
bivector.

float[3] v1 = [ 1.0, 2.0, 0.5 ];
float[3] v2 = [ 3.0, 0.2, 0.0 ];
multivector v3 = v1 * v2;
// result is scalar 1.0*3.0+2.0*0.2+0.5*0.0 and bivector [[ v1 X v2 ]],
combined
printf("scalar part is %f\n",v3.scalar);
printf("vector part is %f,%f,%f\n",v3.vector[0],v3.vector[1],v3.vector[2]);
printf("bivector part is
%f,%f,%f\n",v3.bivector[0],v3.bivector[1],v3.bivector[2]);

That's the kind of thing that needs good language support to be easy to use
and fast (operator overloading and generics would help; making them builtins
would also work).

Maybe after I get a fuller understanding of it I can propose something more
formally.

Sean

"Carlos" <carlos8294 msn.com> wrote in message
news:acurdj$foa$1 digitaldaemon.com...
 and then go back over the fundamental types and operations of D in much
the
 same way as you have extended it for complex numbers, and have D
directly
 support mathematical operations on multivectors using Clifford algebra.
I haven't read completely the article, but I don't think D should support that directly. Not that it wouldn't be good, but as far as I understand
most
 of the programming languages (including C-like or C-based) are designed to
 be general purpose. If geometric algebra is ever included in any language,
 then that language would become (instantly or eventually) completely math
 oriented. Not that I wouldn't like that (I mean, Fortran is so old that I
 can't figure out how someone can still make NEW programs there, but it's
 still the best in math! --maybe that's why) but I'm not quite sure that
this
 should be D's next step. Mainly because of one reason: if right now D (I
 mean, Walter) does that, then D would lose a big group (can't think of
 another word) of programmers: those who aren't interested in math. I know
 that programming is closely related to math, but not everything related to
 programming is math (obviously). For example, if D is better than C, and
 almost every operating system has been done in C, what stops us (D
 programmers) from doing a better OS in D. And if someone is writing an OS
 (not that I am), why would that someone need geometric algebra? It's like
 someone said before: by wanting that, you're wanting to add things that
 aren't really necessary, though they can be needed by some.
May 27 2002
prev sibling parent "anderson" <anderson firestar.com.au> writes:
I agree in most, this could be included in a lib.  I'll bet Walter has to
many other things to do then supporting that level of mathematics as well.

I'd like to point out, if someone else could write an excellent
calculus/applicable maths lib. Walter could provide support by including it
in the lib packages that comes with D, and perhaps adding (or improving
support for) a few of the more orquad ones to the language spec.  I'm not
saying that D should have just any old libs blotting the size, but (at least
in my field) vector mathematics is pretty important in programming.


"Carlos" <carlos8294 msn.com> wrote in message
news:acurdj$foa$1 digitaldaemon.com...
 and then go back over the fundamental types and operations of D in much
the
 same way as you have extended it for complex numbers, and have D
directly
 support mathematical operations on multivectors using Clifford algebra.
I haven't read completely the article, but I don't think D should support that directly. Not that it wouldn't be good, but as far as I understand
most
 of the programming languages (including C-like or C-based) are designed to
 be general purpose. If geometric algebra is ever included in any language,
 then that language would become (instantly or eventually) completely math
 oriented. Not that I wouldn't like that (I mean, Fortran is so old that I
 can't figure out how someone can still make NEW programs there, but it's
 still the best in math! --maybe that's why) but I'm not quite sure that
this
 should be D's next step. Mainly because of one reason: if right now D (I
 mean, Walter) does that, then D would lose a big group (can't think of
 another word) of programmers: those who aren't interested in math. I know
 that programming is closely related to math, but not everything related to
 programming is math (obviously). For example, if D is better than C, and
 almost every operating system has been done in C, what stops us (D
 programmers) from doing a better OS in D. And if someone is writing an OS
 (not that I am), why would that someone need geometric algebra? It's like
 someone said before: by wanting that, you're wanting to add things that
 aren't really necessary, though they can be needed by some.
May 27 2002
prev sibling next sibling parent reply "anderson" <anderson firestar.com.au> writes:
Have you looked into vertex shaders (programs)? I would love to beable to do
matrix/vector operations as quickly and effectiantly as you can in a vertex
shader in program code (rarther then in the shader). OpenGL 2.0 has a real
good spec on this, and it'd be great of D had something along the same
lines.

http://www.3dlabs.com/support/developer/ogl2/whitepapers/index.htm

http://www.3dlabs.com/support/developer/ogl2/whitepapers/OGL2_Shading_Langua
ge_1.2.pdf

But then again, that could probably be done in a lib (parhaps a standard
lib).

PS - Walter I'd be good if the openGL headers/extention could come as part
of the standard libary as it does with C++.  If a 2d lib is going to be
included in the standard libs, why not a multi-platform 3d lib?


"Sean L. Palmer" <seanpalmer earthlink.net> wrote in message
news:acuc30$30hq$1 digitaldaemon.com...
 I think it would be fantastic Walter if you could read this webpage:

 http://www.mrao.cam.ac.uk/~clifford/introduction/intro/intro.html

 and then go back over the fundamental types and operations of D in much
the
 same way as you have extended it for complex numbers, and have D directly
 support mathematical operations on multivectors using Clifford algebra.

 I highly recommend anyone who has any interest in 3D math to read this
page.
 It generalizes the concept of rotation and vector products for all higher
 dimensions by integrating the dot and cross product in much the same way
 that complex numbers integrate real and imaginary parts.

 This stuff is amazing... it's sad that mathematics had taken such a wrong
 turn, but Clifford algebra (aka geometric algebra) attempts to correct the
 problem.

 They've got a C++ template library for multivectors, but D has no
templates
 so it wouldn't be easy to make this general in D from a user perspective.
 It would have to go in the core language design.  (or, you can put in
 generics  ;)

 Sean
May 27 2002
parent reply "Walter" <walter digitalmars.com> writes:
"anderson" <anderson firestar.com.au> wrote in message
news:acusps$hno$1 digitaldaemon.com...
 PS - Walter I'd be good if the openGL headers/extention could come as part
 of the standard libary as it does with C++.  If a 2d lib is going to be
 included in the standard libs, why not a multi-platform 3d lib?
If you want to write it, I can include it.
Jun 11 2002
parent reply "anderson" <anderson firestar.com.au> writes:
"Walter" <walter digitalmars.com> wrote in message
news:ae4bno$1t98$2 digitaldaemon.com...
 "anderson" <anderson firestar.com.au> wrote in message
 news:acusps$hno$1 digitaldaemon.com...
 PS - Walter I'd be good if the openGL headers/extention could come as
part
 of the standard libary as it does with C++.  If a 2d lib is going to be
 included in the standard libs, why not a multi-platform 3d lib?
If you want to write it, I can include it.
Thanks for your reply, Although I'm not lazy (as a programmer I hate duplication of work), I think Pavel Minayev has already almost completed the openGL header port. If Pavel Minayev agrees you could use his. I would however be willing to write up an openGL extention library (although openGL 2 may come out soon). I'd be a real selling point for D to have openGL included, as opengl is to
Jun 11 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"anderson" <anderson firestar.com.au> wrote in message
news:ae527k$2k5e$1 digitaldaemon.com...

 Although I'm not lazy (as a programmer I hate duplication of work), I
think
 Pavel Minayev has already almost completed the openGL header port. If
Pavel
 Minayev agrees you could use his. I would however be willing to write up
an
 openGL extention library (although openGL 2 may come out soon).
I wouldn't mind. =)
 I'd be a real selling point for D to have openGL included, as opengl is to

It was so a few years ago, but it is no longer, I'd say. DX7, and especially DX8 was a _large_ step forward. Now, it is just too high-level even to be compared to OpenGL. Having both ported to D would be great!
Jun 11 2002
next sibling parent "Sean L. Palmer" <seanpalmer earthlink.net> writes:
They are both ported to D.  ;)

I just need to test it more thoroughly and go finish porting the rest of
DirectX (d3dx, dsound, dinput, dplay, dshow, etc, etc)

On the OpenGL side, what is needed now is a D port of GLUT (or FreeGLUT).
I'm interested in OpenGL 2.0 also.

Sean

"Pavel Minayev" <evilone omen.ru> wrote in message
news:ae57ie$2pun$1 digitaldaemon.com...
 "anderson" <anderson firestar.com.au> wrote in message
 news:ae527k$2k5e$1 digitaldaemon.com...

 Although I'm not lazy (as a programmer I hate duplication of work), I
think
 Pavel Minayev has already almost completed the openGL header port. If
Pavel
 Minayev agrees you could use his. I would however be willing to write up
an
 openGL extention library (although openGL 2 may come out soon).
I wouldn't mind. =)
 I'd be a real selling point for D to have openGL included, as opengl is
to

It was so a few years ago, but it is no longer, I'd say. DX7, and
especially
 DX8 was a _large_ step forward. Now, it is just too high-level even to be
 compared to OpenGL. Having both ported to D would be great!
Jun 11 2002
prev sibling parent reply "anderson" <anderson firestar.com.au> writes:
Although I won't mind having directX in the standard lib. It's not a
multi-platform library (although there are some directX libs that run in
lynix), so that has some disadvantages. It would be good to have the
standard libaries standard across all platforms. Also perhaps the cross
platform SDL could be used as the 2d lib, it also includes other cools
features such as sound and device input.

"Pavel Minayev" <evilone omen.ru> wrote in message
news:ae57ie$2pun$1 digitaldaemon.com...
 "anderson" <anderson firestar.com.au> wrote in message
 news:ae527k$2k5e$1 digitaldaemon.com...

 Although I'm not lazy (as a programmer I hate duplication of work), I
think
 Pavel Minayev has already almost completed the openGL header port. If
Pavel
 Minayev agrees you could use his. I would however be willing to write up
an
 openGL extention library (although openGL 2 may come out soon).
I wouldn't mind. =)
 I'd be a real selling point for D to have openGL included, as opengl is
to

It was so a few years ago, but it is no longer, I'd say. DX7, and
especially
 DX8 was a _large_ step forward. Now, it is just too high-level even to be
 compared to OpenGL. Having both ported to D would be great!
I'm hanging on for openGL 2.
Jun 11 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"anderson" <anderson firestar.com.au> wrote in message
news:ae6knn$16fk$1 digitaldaemon.com...

 Although I won't mind having directX in the standard lib. It's not a
 multi-platform library (although there are some directX libs that run in
 lynix), so that has some disadvantages. It would be good to have the
 standard libaries standard across all platforms. Also perhaps the cross
 platform SDL could be used as the 2d lib, it also includes other cools
 features such as sound and device input.
I think that the best idea is to only leave OpenGL in Phobos, since it is the only "official standard" library, and ships with most OSes already. SDL covers a wide range of platforms as well, but one typically has to download it anyhow.
Jun 12 2002
parent "anderson" <anderson firestar.com.au> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:ae709m$1j38$1 digitaldaemon.com...
 "anderson" <anderson firestar.com.au> wrote in message
 news:ae6knn$16fk$1 digitaldaemon.com...

 Although I won't mind having directX in the standard lib. It's not a
 multi-platform library (although there are some directX libs that run in
 lynix), so that has some disadvantages. It would be good to have the
 standard libaries standard across all platforms. Also perhaps the cross
 platform SDL could be used as the 2d lib, it also includes other cools
 features such as sound and device input.
I think that the best idea is to only leave OpenGL in Phobos, since it is the only "official standard" library, and ships with most OSes already. SDL covers a wide range of platforms as well, but one typically has to download it anyhow.
I agree. At the least openGL should be included, because you can do 2d stuff in it as well. If the standard libary gets to big though parhaps it could be broken into parts, later on. ie It could be broken up into FULL - Everything (downloaded first time) CORE - Just the core files, that are updated frequently. (Download for users with FULL) Alternativly an update or patching tool could be used to reduce download size. But for now, it should be kept together, as the openGL headers will barely have any impace on size.
Jun 12 2002
prev sibling parent reply "Christian Schüler" <cschueler gmx.de> writes:
 I think it would be fantastic Walter if you could read this webpage:

 http://www.mrao.cam.ac.uk/~clifford/introduction/intro/intro.html
Yes I know this article, and I have read many other papers on Geometric Algebra as well. I have thought about it myself: "If Walter is to make complex numbers a builtin datatype, he should really make builtin support for Geometric Algebra." This has pros and cons: Pro: Geometric Algebra seems to be what mathematicians and physicists have long looked after: a super-entity for doing computational geometry and physics with a unified "interface". Just as Real numbers incorporate the Integers, and Complex numbers incorporate the Real numbers, Geometric algebra incorporates all the above plus the Quaternions, the Octonions, the Minkowski spaces, the Plücker coordinates, the Homogeneous Projective spaces and that's by far not complete. Rewriting math in G.A. makes many formulas simpler and renders many proofs trivial. So G.A. seems to be the natural choice for a builtin language support. Cons: The "Multivector", which is the basic element of G.A., is a very polymorphic datatype, which must be dynamically typed. Basic operations like "addition" are non-trivial functions when done in software. If I was to write a 3D engine using a generic, full featured Geometric Algebra datatype, it would be SLOW. Geometric Algebra is very elegant to write math, but it's not well suited to be implemented directly in software (at least as long as there is no processor support for it :-). So Geometric Algebra can be used well with pencil and paper to derive algorithms, but the final implementation is best made hand-taylored. So if you ask me if there should be builtin G.A. support in the D language, I have mixed feelings. One part of me says YEEESS, because it would be way cool, and anyway. The other part of mine says no, because such a generic implementation would be useful only for programs with low computation load, like a desktop calculator application. Sean L. Palmer <seanpalmer earthlink.net> schrieb in im Newsbeitrag: acuc30$30hq$1 digitaldaemon.com...
 I think it would be fantastic Walter if you could read this webpage:

 http://www.mrao.cam.ac.uk/~clifford/introduction/intro/intro.html

 and then go back over the fundamental types and operations of D in much
the
 same way as you have extended it for complex numbers, and have D directly
 support mathematical operations on multivectors using Clifford algebra.

 I highly recommend anyone who has any interest in 3D math to read this
page.
 It generalizes the concept of rotation and vector products for all higher
 dimensions by integrating the dot and cross product in much the same way
 that complex numbers integrate real and imaginary parts.

 This stuff is amazing... it's sad that mathematics had taken such a wrong
 turn, but Clifford algebra (aka geometric algebra) attempts to correct the
 problem.

 They've got a C++ template library for multivectors, but D has no
templates
 so it wouldn't be easy to make this general in D from a user perspective.
 It would have to go in the core language design.  (or, you can put in
 generics  ;)

 Sean
May 29 2002
parent "Sean L. Palmer" <seanpalmer earthlink.net> writes:
After reading about it more fully, including the runtime performance
characteristics, I have to agree.

Leave it for a library.

Sean