From: Paul at Home <paul@ru...>  20080520 17:28:44

Yep. The world in question is essentially lying in the XZ ground plane familiar to all standard 3D models, whilst the grid notation I use goes 030 from where 0,0 is "top left" and values increase across or down respectively when thought of in 2D Regards, Paul Johnson. http://www.rubicondev.com  Original Message  From: Patrick Betremieux To: Game Development Algorithms Sent: Tuesday, May 20, 2008 6:17 PM Subject: Re: [Algorithms] Rounding Problem Zc is along the world Z, right ? Your positive world Z goes along the negative Y of your grid, unlike X that goes positive to positive. Hence the reversed fraction. Patrick.  From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Paul at Home Sent: Tuesday, May 20, 2008 10:01 AM To: gdalgorithmslist@... Subject: [Algorithms] Rounding Problem God this is driving me nuts. It should be so simple! I have a world system whereby a grid of 31x31 in grid units is mapped over a range of real values ranging from 15.5 to +15.5 For collision detection reasons, I need a function that will basically do a mod such that when applied to my real X or Z coordinate, it tells me (as a range 01) how far into a grid cell I am. I would expect the routine to return 0.1 if I'm a tenth into a particular grid square. But, whatever combinations of mod,floor,ceil,etc I've tried, when the real coord is negative, I get a 0.9 instead of a 0.1 I'm kinda looking for a float version of "&" iyswim. Any ideas what I'm doing wrong ? ========================================== RoundDown=crt floorf btw tINT GetGridXFromWorld (tF32 WorldX) { return tINT(RoundDown(WorldX+15.5F)); } tINT GetGridYFromWorld (tF32 WorldZ) { return tINT(RoundDown(15.5fWorldZ)); } I would expect this function to return how far into the current square I am as a normalised "percentage". It's changed a lot but this is definitely wrong. I just can't seem to fix it! tF32 Frac=Abs((Zc+0.5F)RoundDown(Zc+0.5F)); Regards, Paul Johnson. http://www.rubicondev.com   This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/  _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist 