Board index » delphi » fixed point math

fixed point math

Hi.  I just read an article on fixed point math, and i could not
seem to figure it out.  I understand that in FP i would use a word or a
longint, and the top byte would be the 10's and the low byte the
fraction, but how do i implement the reading of high and low bits, or
even using this method in pascal? I know how to in assembler(use *l, or
*H instead of *x) but the way i use my variables(i use types, so for
example my variable would be points[2].x) does not allow me to use an asm
block.  Could somebody help me on this?

        Also, i'm wondering if anyone knows how to fill a polygon.  I
just figured out how to rotate 3d points, and i want to be able to fill
them.  Also, how would i figure out which sides to fill for the top, etc?

Thanx, jim

 

Re:fixed point math


Quote
Jim Young wrote:

> Hi.  I just read an article on fixed point math, and i could not
> seem to figure it out.  I understand that in FP i would use a word or a
> longint, and the top byte would be the 10's and the low byte the
> fraction, but how do i implement the reading of high and low bits, or
> even using this method in pascal? I know how to in assembler(use *l, or
> *H instead of *x) but the way i use my variables(i use types, so for
> example my variable would be points[2].x) does not allow me to use an asm
> block.  Could somebody help me on this?

>         Also, i'm wondering if anyone knows how to fill a polygon.  I
> just figured out how to rotate 3d points, and i want to be able to fill
> them.  Also, how would i figure out which sides to fill for the top, etc?

> Thanx, jim

If you have a pentium, don't bother to use fixed point. The fpu is a bit
faster, and you get much better resolution (ie smoother rotation). As for
the polygon fill, I'm not sure, but how about drawing the lines (let's
say you have three points per polygon) and fill in the scanlines while
you work your way down, erhh, let me explain. Draw the line in a buffer.
Then find the entry and exit point (the lines) on each scanline and fill
it.

- Asbj?rn

Re:fixed point math


Fixed Point Math is when you need to speed up your
math calculations in something that doesn't need
lots of accuracy - i.e. 3d Games, Simulations - most
3d stuff.

So, instead of making a cube that's 1 unit in size and
using real or double or extended and getting fractions when
you rotate it, you use, say 100 and use DIV instead of /
to speed up the calculations.

What happens is that accuracy is reduced and your object
"wobbles" a bit but you speed up calculation. As for
separating the bits to make it a decimal, I think that that's
what the computer would do anyway if you used Floating
Point Math. Not much point there.

Darky.
--
--------------------------------------------------------------
/------\/-----\/-----\/-\  /-\/------\/-----\/-----\/---\  /-\
\| /-\ || /-\ || /-\ || | /  /| /\/\ || /-\ || /-\ ||    \ | |
 | | | || \_/ || \_/ || |/ /_ | |||| || | | || | | || |\  \| |
 | | | || /-\ || /-\| | /-\  || |\/| || | | || | | || | \  \ |
/| \-/ || | | || | | \| | |  || |  | || \_/ || \_/ || |  \   |
\______/\_/ \_/\_/ \_/\_/ \__/\_/  \_/\_____/\_____/\_/   \__/
--------- http://connexus.apana.org.au/~mikuto/darky ---------

Re:fixed point math


Quote
DarkMoon Rising wrote:

> Fixed Point Math is when you need to speed up your
> math calculations in something that doesn't need
> lots of accuracy - i.e. 3d Games, Simulations - most
> 3d stuff.

Of cource, that's if you're not targeting a Pentium. If the target is a
Pentium processor, floating point is a bit faster (sometimes much,
depends on the code), and all the accuracy is preserved.

- Asbj?rn

Re:fixed point math


Quote
Asbj?rn wrote:

> DarkMoon Rising wrote:

> > Fixed Point Math is when you need to speed up your
> > math calculations in something that doesn't need
> > lots of accuracy - i.e. 3d Games, Simulations - most
> > 3d stuff.

> Of cource, that's if you're not targeting a Pentium. If the target is a
> Pentium processor, floating point is a bit faster (sometimes much,
> depends on the code), and all the accuracy is preserved.

Right. And even on a 486, fixed-point is not much faster.

--

Personal Pages                  http://www.midnightbeach.com/jon
Programming Publications        http://www.midnightbeach.com/jon/pubs
Home School Resource List       http://www.midnightbeach.com/hs

Other Threads