January 13, 2006
Lucas Goss wrote:
> BCS wrote:
> 
>>
>> If you are looking to do 3D math I have a fairly compete library.
>>
>> http://www.cs.uidaho.edu/~temp0092/point_math.d
>>
>> This is an older version (the newer one is on a differnt system), I will post the newer one in a few hours.
> 
> 
> Thanks! (sorry I was a little slow to respond).
> 
> My vector class actually looked pretty similar (which means I must be doing something right :) ), though I'm using templates so that you can use float, double, or real. I'd post mine but I no longer have a web site (I'll have to remedy that soon).

Making it into a template ought not to be to bad as the actual type is done using a alias. (if you don't see that in the version you have, I put up a more recent version a while back).

I have some more code that can go along with it (matrix transformations etc.), If i can find it I'll put it up over the weekend.
January 14, 2006
BCS wrote:
> 
> Making it into a template ought not to be to bad as the actual type is done using a alias. (if you don't see that in the version you have, I put up a more recent version a while back).
> 

Yeah, that's how I'm doing it. I have:
alias TVector3!(float) Vector3f;
alias TVector3!(double) Vector3d;
alias TVector3!(real) Vector3;

> I have some more code that can go along with it (matrix transformations etc.), If i can find it I'll put it up over the weekend.

I'd like to see it if you can find it. I'm doing my matrix stuff now and I have part of it done, but I'm not positive about what all methods to include (I have all the operators done). Currently I have: adjoint, determinant, (get/set)Row, (get/set)Column, inverse, quadraticForm, transpose, and orthonormalize. Right now I'm getting ready to add eigenDecomposition and after that some euler conversions.
January 15, 2006
In article <dqb9jm$2t6$1@digitaldaemon.com>, Lucas Goss says...
>
>BCS wrote:
>> I have some more code that can go along with it (matrix transformations etc.), If i can find it I'll put it up over the weekend.
>
>I'd like to see it if you can find it. I'm doing my matrix stuff now and I have part of it done, but I'm not positive about what all methods to include (I have all the operators done). Currently I have: adjoint, determinant, (get/set)Row, (get/set)Column, inverse, quadraticForm, transpose, and orthonormalize. Right now I'm getting ready to add eigenDecomposition and after that some euler conversions.

I was sticking to just the geomectric stuff like transformations (translate ,
rotate, skew), inverse and combining. The sticky one has been inverse (To many
special cases)


January 15, 2006
> In article <dqb9jm$2t6$1@digitaldaemon.com>, Lucas Goss says...
> 
> I was sticking to just the geomectric stuff like transformations (translate ,
> rotate, skew), inverse and combining. The sticky one has been inverse (To many
> special cases)
> 

Ah, I'm modeling mine off of David Eberly's books. For the inverse I just use cofactors (courtesy of David Eberly :) ).
January 17, 2006
In article <dqcc8u$vqr$1@digitaldaemon.com>, Lucas Goss says...
>
>Ah, I'm modeling mine off of David Eberly's books. For the inverse I just use cofactors (courtesy of David Eberly :) ).

I I'm using row ops (not sure what the method is called)

I've got most of it working and tested, I'll get it posted sometime tomorrow. BTW, is the point3d struct useful enough to merit inclusion in phobos and/or aries?


January 17, 2006
BCS wrote:
> In article <dqcc8u$vqr$1@digitaldaemon.com>, Lucas Goss says...
> 
>>Ah, I'm modeling mine off of David Eberly's books. For the inverse I just use cofactors (courtesy of David Eberly :) ).
> 
> 
> I I'm using row ops (not sure what the method is called)

I believe it's Gaussian elimination :)

BTW, I've also got a 3d math module: http://158.75.59.9/~h3/tmp/maths.d


-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d-pu s+: a-->----- C+++$>++++ UL P+ L+ E--- W++ N++ o? K? w++ !O !M V? PS- PE- Y PGP t 5 X? R tv-- b DI- D+ G e>+++ h>++ !r !y
------END GEEK CODE BLOCK------

Tomasz Stachowiak  /+ a.k.a. h3r3tic +/
January 17, 2006
Tom S wrote:
> BCS wrote:
> 
>> In article <dqcc8u$vqr$1@digitaldaemon.com>, Lucas Goss says...
>>
>>> Ah, I'm modeling mine off of David Eberly's books. For the inverse I just use cofactors (courtesy of David Eberly :) ).
>>
>>
>>
>> I I'm using row ops (not sure what the method is called)
> 
> 
> I believe it's Gaussian elimination :)
> 
> BTW, I've also got a 3d math module: http://158.75.59.9/~h3/tmp/maths.d
> 
> 
It's up at http://www.cs.uidaho.edu/~temp0092/point_lib.d

Consider it bata (a.k.a. Probably has a few bugs). The unittest doesn't cover all cases and omits a few functions all together. Also I have a few function I might add later
January 29, 2006
Lucas Goss wrote:
> Is there any advantage or benefit to writing a class as:
> 
> class SomeClass
> {
>    float number[3];
>    //...
> }
> 
> Instead of:
> 
> class SomeClass
> {
>    float number1;
>    float number2;
>    float number3;
>    //...
> }
> 
> I see a lot of C++ classes that are like the first. Could it be memory alignment reasons? Or maybe for speed?

Referring to array elements requires a few extra operations. For starters, you have to LOAD the base_address. Then, depending on your architecture you may have to do some math (like a multiply) to figure out the offset address and finally perform another LOAD to get the actual element into memory. This is definitely worth it if you are going to be processing a large number of elements because the overhead associated with an array is ameliorated. (only only load the base address once and most machines tend to have address generation units).
On the other hand, if you are going to be performing several extra operations just to increment a couple integers then the performance may suffer.

With that said, I don't know if anybody did a benchmark of a vec3 implemented with an array vs. a vec3 implemented with 3 variables.

Also, unless this class is on the absolute critical path, the performance gain will be less than insignificant.
January 30, 2006
nick wrote:
> With that said, I don't know if anybody did a benchmark of a vec3 implemented with an array vs. a vec3 implemented with 3 variables.
> 
> Also, unless this class is on the absolute critical path, the performance gain will be less than insignificant.

To get the best of both worlds, the following should work:

struct vec3 {
	union {
		float number[3];
		struct {
			float x,y,z;
		}
	}
}
January 30, 2006
Tom S wrote:
> BCS wrote:
>> In article <dqcc8u$vqr$1@digitaldaemon.com>, Lucas Goss says...
>>
>>> Ah, I'm modeling mine off of David Eberly's books. For the inverse I just use cofactors (courtesy of David Eberly :) ).
>>
>>
>> I I'm using row ops (not sure what the method is called)
> 
> I believe it's Gaussian elimination :)
> 
> BTW, I've also got a 3d math module: http://158.75.59.9/~h3/tmp/maths.d
> 
> 
I'm  curious, what do you have in:
	import core.common;
	import core.serializer;

I see this is probably pulled from core.serializer:
	mixin Serializer.RawStruct;

Would you be open to showing those as well?