Results 1 to 13 of 13

Thread: Loss Of Precision

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Loss Of Precision

    Precision of Vectors:

    I have a number that i'm trying to pass to my MakeVector function, which accepts a single as the datatype. The number is 22201.97376. So I pass that number along to makevector but the problem is it chops it down to two decimal places... and I need those extra points of precision to make things work. Is there anything I can do? I can't change the data type because eventually it ends up as a single, when it is stored in a D3DVector.


    "X-mas is 24.Desember you English morons.." - NoteMe

  2. #2
    Member Yhoko's Avatar
    Join Date
    May 2002
    Posts
    47

    Re: Loss Of Precision

    Show that function pls?
    - Yhoko


    Try my Games
    * [VB6] YDK - Yhoko's Development Kit
    * [VB6] HackV1 - two-player puzzle/strategy
    * [VB6] Xen - extended Gen

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Loss Of Precision

    VB Code:
    1. Public Function MakeVector(x As Single, y As Single, z As Single) As D3DVECTOR
    2.     With MakeVector
    3.         .x = x
    4.         .y = y
    5.         .z = z
    6.     End With
    7.    
    8. End Function

    Then I use it like so:
    Mesh.Move MakeVector( 22201.97376, 0, -5 )


    "X-mas is 24.Desember you English morons.." - NoteMe

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Loss Of Precision

    Where did you get the idea that it chops it down to two decimal places though? Single is sufficient enough. Cause if you use Doubles, DX is gonna convert it to Single anyways, and might slow your program down. However in other cases, Double is ok. Such as for collision when Single isn't accurate enough.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Loss Of Precision

    I got the idea from when I stepped through the code... when this line:
    Mesh.Move MakeVector( 22201.97376, 0, -5 )

    is called it goes in to the MakeVector function which reports the x variables as 22201.97, so it obviously loses 3 digits of precision.


    "X-mas is 24.Desember you English morons.." - NoteMe

  6. #6
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Loss Of Precision

    Hmmmm, that's funny. I did an experiment, and no matter what I did, it always turned into 22201.97. I guess VB converts it automatically.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Loss Of Precision

    Yea... I have no idea what to do about it =/


    "X-mas is 24.Desember you English morons.." - NoteMe

  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Loss Of Precision

    Stab in the dark but have you tried this?

    Mesh.Move MakeVector( 22201.97376F, 0, -5 )
    I don't live here any more.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Loss Of Precision

    Appending F doesn't do anything, just a compile error.


    "X-mas is 24.Desember you English morons.." - NoteMe

  10. #10
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Loss Of Precision

    Try # instead. It might work.

  11. #11
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Loss Of Precision

    What D3DVECTOR vector are you using. The one in DX? If so, it is float by default. Your GPU is using floats. It is made to be fast not for precission. So it is nothing you can do about it except making your own struct/class....

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Loss Of Precision

    Well all the functions expect a D3DVector so how would I go about implementing that note?


    "X-mas is 24.Desember you English morons.." - NoteMe

  13. #13
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Loss Of Precision

    I am not sure what you are doing here, but usualy it is not nesesary in a game. If it is for you, then the other functions have to be rewritten too. Remember that the drawing does never have to be as precise as the calculation. So you can have two sets of coordinates and vectors. One for drawing, and one for collision detection or what ever...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width