# Board index » delphi » Having a small problem with 3D

## Having a small problem with 3D

Hey all!

As you could tell from the title of this post, im having a problem
with a small 3d program im writting. Whats going on is this :

I have a small program which rotates a 3d object around the Z axis by
using the left/right arrow keys. The object is very similar to a chess
board (made up of a series of squares) The problem that is arising is
when ANY of the vertices Y values of this object go outside the range
of -32 to 33 a value of 130 is added (or subtracted) to the Y value of
the vertice. (If the -32 range is exceeded, 130 is subtracted, else if
the 33 range is exceeded, 130 is added)

It has got me stumped as to WHY this is happening. Ive asked several
friends who are into programming, but the problem has illuded them as
well.

If anyone out there has some ideas as to what could be causing this
problem i'd love to hear from you.

Thank you :)

Andrew Burch - (Jesder)

## Re:Having a small problem with 3D

Does the range go like this...

...30, 31, 32, 33, 160, 161, 162...

and

...-30, -31, -32, -162, -163, -164...

Need to see the code.

-dave

On Wed, 08 Dec 1999 08:31:07 GMT, jes...@one.net.au (Andrew Burch)
wrote:

##### Quote
>Hey all!

>As you could tell from the title of this post, im having a problem
>with a small 3d program im writting. Whats going on is this :

>I have a small program which rotates a 3d object around the Z axis by
>using the left/right arrow keys. The object is very similar to a chess
>board (made up of a series of squares) The problem that is arising is
>when ANY of the vertices Y values of this object go outside the range
>of -32 to 33 a value of 130 is added (or subtracted) to the Y value of
>the vertice. (If the -32 range is exceeded, 130 is subtracted, else if
>the 33 range is exceeded, 130 is added)

>It has got me stumped as to WHY this is happening. Ive asked several
>friends who are into programming, but the problem has illuded them as
>well.

>If anyone out there has some ideas as to what could be causing this
>problem i'd love to hear from you.

>Thank you :)

>Andrew Burch - (Jesder)

## Re:Having a small problem with 3D

##### Quote
Andrew Burch wrote in message <384e0...@pink.one.net.au>...

..
##### Quote

>If anyone out there has some ideas as to what could be causing this
>problem i'd love to hear from you.

could you not post the (relevant) source to the newsgroup ? It's a bit
difficult to help you when you have not posted the actual sorce code
.. (or the algorithm)

--
Jeremy O'Connor
line 2
line 3
line 4

## Re:Having a small problem with 3D

##### Quote
Andrew Burch wrote:
> Hey all!

> As you could tell from the title of this post, im having a problem
> with a small 3d program im writting. Whats going on is this :

> I have a small program which rotates a 3d object around the Z axis by
> using the left/right arrow keys. The object is very similar to a chess
> board (made up of a series of squares) The problem that is arising is
> when ANY of the vertices Y values of this object go outside the range
> of -32 to 33 a value of 130 is added (or subtracted) to the Y value of
> the vertice. (If the -32 range is exceeded, 130 is subtracted, else if
> the 33 range is exceeded, 130 is added)

> It has got me stumped as to WHY this is happening. Ive asked several
> friends who are into programming, but the problem has illuded them as
> well.

> If anyone out there has some ideas as to what could be causing this
> problem i'd love to hear from you.

If things change by 128 (not 130), it starts to sound like a "signed
byte" problem.  Is the number being treated as a byte?  Is it considered
signed?  (Apparently it is, since you mention -32).  If it "wraps" at 32,
it sounds like only the lower 6 bits are being used (five
bits of precision and one of sign).

Bob Schor

## Re:Having a small problem with 3D

##### Quote
Bob Schor wrote in message <384E65D5.A204F...@pitt.edu>...
>Andrew Burch wrote:

>> Hey all!

>> As you could tell from the title of this post, im having a problem
>> with a small 3d program im writting. Whats going on is this :

>> I have a small program which rotates a 3d object around the Z axis by
>> using the left/right arrow keys. The object is very similar to a chess
>> board (made up of a series of squares) The problem that is arising is
>> when ANY of the vertices Y values of this object go outside the range
>> of -32 to 33 a value of 130 is added (or subtracted) to the Y value of
>> the vertice. (If the -32 range is exceeded, 130 is subtracted, else if
>> the 33 range is exceeded, 130 is added)

>> It has got me stumped as to WHY this is happening. Ive asked several
>> friends who are into programming, but the problem has illuded them as
>> well.

>> If anyone out there has some ideas as to what could be causing this
>> problem i'd love to hear from you.

>     If things change by 128 (not 130), it starts to sound like a "signed
>byte" problem.  Is the number being treated as a byte?  Is it considered
>signed?  (Apparently it is, since you mention -32).  If it "wraps" at 32,
>it sounds like only the lower 6 bits are being used (five
>bits of precision and one of sign).

>Bob Schor

Very interesting!
I would like to have a look at this!
Could you please post me the procedure that does this rotating of yours!

Heinr...@mailroom.com

Chaou
Heinrich

Check my web-site:
http://homes.arealcity.com/heinrichshomepage/
Includes a complete TP tutoriul and much more!
Updated regularly

## Re:Having a small problem with 3D

##### Quote
jes...@one.net.au (Andrew Burch) wrote:

Thank you to the people who took interest and the time to reply to my
3D problem. I appreciate it! At 1am yesterday morning i actually
worked out what was going wrong! Becuase i use Longints with my fixed
point math, i needed to set my X and Y variables to longints as well,
and not just integer. That was all the problem was (its always the
smallest of things to cause the biggest problems ;)

So again thank you to those who offered their assistance, very muchly
appreciated!

Kinds Regards,

Andrew Burch

## Re:Having a small problem with 3D

JRS:  In article <3855a...@pink.one.net.au> of Tue, 14 Dec 1999
03:02:54 in news:comp.lang.pascal.borland, Andrew Burch

##### Quote
<jes...@one.net.au> wrote:
>jes...@one.net.au (Andrew Burch) wrote:

>Thank you to the people who took interest and the time to reply to my
>3D problem. I appreciate it! At 1am yesterday morning i actually
>worked out what was going wrong! Becuase i use Longints with my fixed
>point math, i needed to set my X and Y variables to longints as well,
>and not just integer. That was all the problem was (its always the
>smallest of things to cause the biggest problems ;)

That suggests to me that you *may* not have all run-time checks ON; it
is a pity that the compilers have them OFF by default (IIRC).

All such checks should be on all the time (exceptions include \$I) except
in well-tested inner loops, certain peculiar bits of code, and, maybe,
in fully-tested speed-critical final releases.

Almost no BP/TP program should now be speed-critical, since 32-bit
Delphi console-mode will be faster.

Web <URL: http://www.merlyn.demon.co.uk/pas-norm.htm> refers.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
<URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
<URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.