News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Which is the right translation?

Started by Farabi, November 20, 2008, 07:24:02 AM

Previous topic - Next topic

Farabi

I want to translate this C++ Structure

typedef dReal dVector4[4];
typedef dReal dMatrix3[4*3];

struct dMass {
  dReal mass;
  dVector4 c;
  dMatrix3 I;


Which is the right one?
This one?

dMass struct
mass dword 0
_c real4 4 dup(0.0)
_i real4 12 dup (0.0)
dMass ends


Or this one?


dMatrix3 struct
d1 real4 0.0
d2 real4 0.0
d3 real4 0.0
d4 real4 0.0
d5 real4 0.0
d6 real4 0.0
d7 real4 0.0
d8 real4 0.0
d9 real4 0.0
d10 real4 0.0
d11 real4 0.0
d12 real4 0.0

dMatrix3 ends

dVector4 struct
d1 real4 0.0
d2 real4 0.0
d3 real4 0.0
d4 real4 0.0
dVector4 ends

dMass struct
mass dword 0
_c real 4dVector4 <?>
_i real4 dMatrix3 <?>
dMass ends

?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

None :P

QuotedReal mass;
You made it a dword.
And I would check how big a 'dReal' should be - is it only real4?

As for the rest, I think the first looks okay.
Although, you might need the definitions of dVector4 and dMatrix3 elsewhere, so it's worth defining them separately and using their definitions (but you can still define them with dup.)



Something like...
dReal typedef real4     ;only a real4?

dVector4 struct
    ptA dReal ?
    ptB dReal ?
    ptC dReal ?
    ptD dReal ?
dVector4 ends

dMatrix3 struct
    v1 dVector4 <?>
    v2 dVector4 <?>
    v3 dVector4 <?>
dMatrix3 ends

dMass struct
    mass dReal ?
    _c dVector4 <>
    _I dMatrix3 <>
dMass ends
No snowflake in an avalanche feels responsible.

Farabi

Hi tedd,
Sorry to take your time.

I found this on the C++ include file


#if defined(dSINGLE)
typedef float dReal;
#ifdef dDOUBLE
#error You can only #define dSINGLE or dDOUBLE, not both.
#endif // dDOUBLE
#elif defined(dDOUBLE)
typedef double dReal;
#else
#error You must #define dSINGLE or dDOUBLE
#endif

What does it mean?

Also I googling and got this definition of dReal http://www.shogun-toolbox.org/doc/common_8h.html

typedef double DREAL
Type DREAL is 8 bytes in size.

Dont know which is right. I upload my source and the dll just incase you want to see what Im doing.
Put this on your creation message


.elseif uMsg==WM_CREATE
invoke InitODE
invoke TestODE

[attachment deleted by admin]
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Problem solved.
Structure is accepted and the function is working.
dReal is an alias of real4 and float.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

tenkey

Only if you #define dSINGLE.

If you #define dDOUBLE, dReal becomes the alias of REAL8 and double.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

Farabi

Quote from: tenkey on November 22, 2008, 05:49:45 AM
Only if you #define dSINGLE.

If you #define dDOUBLE, dReal becomes the alias of REAL8 and double.
Fortunately the dll is only accept real4.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"