1. brain teaser

------=_NextPart_000_0005_01BE9B38.1D283240
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all, Col22 here with
a little programming brain teaser for you.

I have been scribbling a little 3d engine recently, and without sending=20
you to sleep with the details I had this little problem in the middle.

I have a player facing angle called playera.
I have a x viewing angle called viewang
I have various angles to check "ang",
if they are in the feild of view, viewang.
The angles playera and viewang are in degrees.
veiwang can be from 45 to 180
playera can be from 1 to 360

There's the background, heres the puzzle.
Fill in the missing condition to make the code find if=20
the angle "ang" is within the given range minang to maxang.


minang =3D playera - veiwang / 2
maxang =3D playera + veiwang / 2
if xxxxx missing condition xxxxx then=20
    blah
    blah
end if

.....................................................

I have done this a few ways but am not happy with them.
I feel there is a concise and efficient way of doing it=20
but it escapes me for the moment.
Whatever you come up with as a solution I would be happy
to hear from you. Thanks, Col22


------=_NextPart_000_0005_01BE9B38.1D283240
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all, Col22 here with<BR>a little =
programming=20
brain teaser for you.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have been scribbling a little 3d =
engine recently,=20
and without sending <BR>you to sleep with the details I had this little =
problem=20
in the middle.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have a player facing angle called =
playera.<BR>I=20
have a x viewing angle called viewang<BR>I have various angles to check=20
"ang",<BR>if they are in the feild of view, viewang.<BR>The angles =
playera and=20
viewang are in degrees.<BR>veiwang can be from 45 to 180<BR>playera can =
be from=20
1 to 360</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>There's the background, heres the =
puzzle.<BR>Fill=20
in the missing condition to make the code find if <BR>the angle "ang" is =
within=20
the given range minang to maxang.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>minang =3D playera - veiwang / =
2<BR>maxang =3D=20
playera + veiwang / 2<BR>if xxxxx missing condition xxxxx then=20
<BR>&nbsp;&nbsp;&nbsp; blah<BR>&nbsp;&nbsp;&nbsp; blah<BR>end =
if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
V>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have done this a few ways but am not =
happy with=20
them.<BR>I feel there is a concise and efficient way of doing it <BR>but =
it=20
escapes me for the moment.<BR>Whatever you come up with as a solution I =
would be=20

------=_NextPart_000_0005_01BE9B38.1D283240--

new topic     » topic index » view message » categorize

2. Re: brain teaser

Try this:

When you first load the settings and stuff(eg player pos, sin/cos tables
ect...) Set up the min/max view angle...then as they move just add the
correct value to min view angle(and then add 135(180-45) and you get your
max view angle....this ~SHOULD~ keep everything lined up correctly...

eg..

plarer angle = x
player minview = x + viewangle min
player mxview = player minview + 135

~action: player moves his/her view

plarer angle = x
player minview = x + viewangle min + 5
player mxview = player minview + 135

this ~looks~ right
you tell me

The all knowing Grape(just thinks he is)
PS.. let me know if this works


>From: Col22 <col22 at SUNG79.FREESERVE.CO.UK>
>Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU>
>To: EUPHORIA at LISTSERV.MUOHIO.EDU
>Subject: brain teaser
>Date: Mon, 10 May 1999 22:54:52 +0100
>
>Hi all, Col22 here with
>a little programming brain teaser for you.
>
>I have been scribbling a little 3d engine recently, and without sending
>you to sleep with the details I had this little problem in the middle.
>
>I have a player facing angle called playera.
>I have a x viewing angle called viewang
>I have various angles to check "ang",
>if they are in the feild of view, viewang.
>The angles playera and viewang are in degrees.
>veiwang can be from 45 to 180
>playera can be from 1 to 360
>
>There's the background, heres the puzzle.
>Fill in the missing condition to make the code find if
>the angle "ang" is within the given range minang to maxang.
>
>
>minang = playera - veiwang / 2
>maxang = playera + veiwang / 2
>if xxxxx missing condition xxxxx then
>     blah
>     blah
>end if
>
>.....................................................
>
>I have done this a few ways but am not happy with them.
>I feel there is a concise and efficient way of doing it
>but it escapes me for the moment.
>Whatever you come up with as a solution I would be happy
>to hear from you. Thanks, Col22
>


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: brain teaser

<html>
<font face=3D"arial" size=3D2>col22 wrote:<br>
&gt;Fill in the missing condition to make the code find if <br>
&gt;the angle &quot;ang&quot; is within the given range minang to
maxang.<br>
&gt;minang =3D playera - veiwang / 2<br>
&gt;maxang =3D playera + veiwang / 2<br>
&gt;if xxxxx missing condition xxxxx then <br>
=A0&gt;=A0 blah<br>
=A0&gt;=A0 blah<br>
&gt;end if<br>
<br>
</font><font size=3D3>looks to me like you need the &quot;range&quot;
function...<br>
<br>
<br>
function range(atom testvalue, atom lower, atom upper)<br>
&nbsp;&nbsp; return (lower&lt;=3Dtestvalue) and (testvalue&lt;=3Dupper)<br>
end function<br>
minang =3D playera - veiwang / 2<br>
maxang =3D playera + veiwang / 2<br>
if range(ang,minang,maxang) then <br>
=A0 blah<br>
=A0 blah<br>
end if<br>
<br>
since you are using the function in an if..then, it cannot operate<br>
(easily) upon sequences, however, it can be easily adapted to<br>
work with sequences and objects (just change the declarations<br>
from atom to object)<br>
the conditional testing would change tho, as you would be<br>
returning sequences of true/false values...<br>
<br>
HTH, take care--Hawke'<br>
<br>
</font></html>

new topic     » goto parent     » topic index » view message » categorize

4. Re: brain teaser

Col22 wrote:

>I have a player facing angle called playera.
>I have a x viewing angle called viewang
>I have various angles to check "ang",
>if they are in the feild of view, viewang.
>The angles playera and viewang are in degrees.
>veiwang can be from 45 to 180
>playera can be from 1 to 360
>
>There's the background, heres the puzzle.
>Fill in the missing condition to make the code find if
>the angle "ang" is within the given range minang to maxang.
>
>
>minang = playera - veiwang / 2
>maxang = playera + veiwang / 2
>if xxxxx missing condition xxxxx then
>     blah
>     blah
>end if

Maybe I'm missing something ...

how about:
    if ang >= minang and ang <= maxang then
        blah blah
    end if

of course there is also the possibility that minang is actually larger than
maxang.  In which case it becomes a little more complicated.  Try this:

if minang < maxang then
    if ang >= minang and ang <= maxang then
        blah_blah()
    end if
elsif ang >=maxang or ang <= minang then
    blah_blah()
end if

It could be done all in one if statement but would be harder to read:

if (ang <= maxang and ang >= minang) or
  (minang > maxang and not(ang <= maxang and ang >= minang)) then
    blah_blah ()
end if

These solutions may or may not work since I have not tested them and they
may or may not be any better than what you came up with yourself.

Hope this helps
Lewis Townsend


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu