﻿ Raycaster from Planet Disco
23 May, 2013, 20:17:43
 OmnomIRC You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

 Pages: 1 [2]   Go Down
 Author Topic: Raycaster from Planet Disco -  (Read 722 times) 0 Members and 1 Guest are viewing this topic.
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Last Login: 20 May, 2013, 21:27:24
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2735

Total Post Ratings: +373

 « Reply #15 on: 21 February, 2012, 01:55:46 » 0

Yeah, if you have a 96 byte table stored in 0.8 fixed point, you could just do Dist**{X+Table}.
 Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Last Login: 21 May, 2013, 02:03:21
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022

Total Post Ratings: +1019

 « Reply #16 on: 21 February, 2012, 02:42:47 » +2

By the way, Axe internally calculates sine by the following pseudo code:

Mod the argument X by 256 (Sine is cyclic)
If X < 128 return X*(128-X)/32 (An approximation of a sine hump)
If X > 128 return (256-X)*(128-X)/32 (An approximation of a negative sine hump)

Cosine is just sin(X+64) of course.  Each of these use only a single multiplication so it's going to be fairly fast.  If you want the result to be in the full range [-32768 to 32767] instead of [-128 to 127] multiply by 8 instead of dividing by 32 in your custom routine.  Or for 8.8 format, just divide by 16 instead.
 « Last Edit: 21 February, 2012, 02:46:40 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
Builderboy
Physics Guru

Offline

Gender:
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642

Total Post Ratings: +589

 « Reply #17 on: 21 February, 2012, 03:00:47 » 0

Why didn't you divide by 16 in the first place?  8.8 format seems a lot more useful than the current range of the trig functions.
 Logged

ZippyDee

Offline

Gender:
Last Login: 12 May, 2013, 10:03:36
Date Registered: 21 March, 2011, 03:15:07
Location: Yes.
Posts: 704

Total Post Ratings: +73

 « Reply #18 on: 21 February, 2012, 03:55:35 » 0

yeah, but that's compressed programs, with ununderstable code (what, I'm a newbie ?)
Compressed programs? Neither of the three have any sort of compression going on (that I know of), it's just regular Axe.
Yeah, but I meant without any explication of how it work (bad English powaaa)
The term you're looking for is "optimized," not "compressed." Compression is where a set of data is encoded in such a way that the resulting data is smaller in size than the original data. Optimization is when a program is modified so it runs faster or uses less memory, or otherwise becomes more efficient than before.
 Logged

Pushpins 'n' stuff...

Xeda112358
Xombie. I am it.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)

Online

Date Registered: 31 October, 2010, 08:46:36
Location: Land of Little Cubes and Tea, NY
Posts: 3760

Total Post Ratings: +609

 « Reply #19 on: 21 February, 2012, 04:10:48 » 0

@Quigibo: Wow, that is nice
 Logged

Latest update (possibly incomplete)
My pastebin
Spoiler for FileSyst:
FileSyst is an application that provides a folder and filesystem for the TI-83+/84+ calculators. It is designed to be easy to access and use in BASIC, and it can be used to access game files and save data, or to create a command prompt, among other things:

Spoiler for Graphiti:
This is a graph explorer for graph theory. It will require lots of work to finish. Currently you can:
Add edges (direction not shown, but they are directed)
Arrange vertices in a circle (in the future, you will be able to define levels of rings and the number of nodes in each)
Create complete graphs quickly

Plans:
Deleting edges
Multiple graphs support
Arrows for directed graphs
Planarity testing
Matrix operations
Weighted edges
Chromatic polynomials
Chromatic numbers

Spoiler for Stats:

Samocal             [o---------]
Virtual Processor   [o---------]
EnG                 [oo--------]
Grammer             [ooo-------]
AsmComp             [ooo-------]
Partex              [oooo------]
BatLib              [oooooooo--]
Grammer82           [----------]
Grammer68000        [----------]

Pseudonyms:  Zeda, Xeda, Thunderbolt
Languages:   English, français
Programming: z80 Assmebly
Grammer
TI-BASIC (83/84/+/SE, 89/89t/92)
Known For:   -Creator of the Grammer programming language
(Winning program of zContest2011)
-BatLib- One of the most feature packed libraries for BASIC programmers available
with over 100 functions and a simple programming language
-Learning to program z80 in hexadecimal before using an assembler (no computer was
available!)
╔═╦╗░╠═╬╣▒║ ║║▓╚═╩╝█

LincolnB
Check It Out Now
LV9 Veteran (Next: 1337)

Offline

Gender:
Last Login: 20 May, 2013, 05:36:22
Date Registered: 02 May, 2011, 00:56:28
Location: Utah Valley
Posts: 1114

Topic starter
Total Post Ratings: +121

 « Reply #20 on: 21 February, 2012, 05:50:10 » 0

I believe to fix the fishbowl effect you just need to multiply the ray distance by the Cos() of the angle between your front view and the angle of the ray.

What does this mean???
 Logged

Completed Projects:
>> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
>> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.

Spoiler for Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)

Builderboy
Physics Guru

Offline

Gender:
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642

Total Post Ratings: +589

 « Reply #21 on: 21 February, 2012, 06:39:30 » 0

Let's say you cast a ray.  Your player will already be facing a certain angle, and the ray will be cast at an angle that is at an offset to the angle the player is facing.  You take the cosine of the difference between the ray's angle and the player's angle, and then you multiply that by the ray's distance.  This new value is the new ray distance.
 Logged

Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Last Login: 21 May, 2013, 02:03:21
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022

Total Post Ratings: +1019

 « Reply #22 on: 21 February, 2012, 09:49:42 » 0

Why didn't you divide by 16 in the first place?  8.8 format seems a lot more useful than the current range of the trig functions.
I wish I had.  I added the sin/cos routines before I introduced 8.8 operations and so at the time, I chose the range because it would be convenient to be able to store the result into a single byte in memory.  Its too late to make a change like that now unfortunately, but when it comes down to it, it only costs 1 byte to convert it in Axe and the resolution you lose is small since the routine is an approximation anyway.

Also, the pseudo code is not literal to how Axe does the operation.  Its far more optimized without multiplication or division, but rather a single routine that does everything together bit by bit.
 « Last Edit: 21 February, 2012, 09:52:16 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
LincolnB
Check It Out Now
LV9 Veteran (Next: 1337)

Offline

Gender:
Last Login: 20 May, 2013, 05:36:22
Date Registered: 02 May, 2011, 00:56:28
Location: Utah Valley
Posts: 1114

Topic starter
Total Post Ratings: +121

 « Reply #23 on: 21 February, 2012, 23:56:48 » 0

OK Builder, I think I get it.

Is it possible to take the inverse cosine of an 8.8 number in Axe? If not, I'd like to request that feature.
 Logged

Completed Projects:
>> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
>> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.

Spoiler for Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)

Builderboy
Physics Guru

Offline

Gender:
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642

Total Post Ratings: +589

 « Reply #24 on: 22 February, 2012, 00:10:42 » 0

Not that I know of, but you should probably check the commands list, that will tell you anything you need to know.  What do you need inverse cosine for?
 Logged

LincolnB
Check It Out Now
LV9 Veteran (Next: 1337)

Offline

Gender:
Last Login: 20 May, 2013, 05:36:22
Date Registered: 02 May, 2011, 00:56:28
Location: Utah Valley
Posts: 1114

Topic starter
Total Post Ratings: +121

 « Reply #25 on: 22 February, 2012, 02:01:28 » 0

More 3D related stuff - I'm trying to set up some code that detects whether or not a given object on the unit circle (centered at your character, radius=distance between you and object) is in your FOV.
 Logged

Completed Projects:
>> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
>> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.

Spoiler for Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)

Builderboy
Physics Guru

Offline

Gender:
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642

Total Post Ratings: +589

 « Reply #26 on: 22 February, 2012, 02:42:10 » 0

Hmm there is probably a way to do that with dot products to avoid a large amount of trig, but couldn't you just use inverse tangent?
 Logged

LincolnB
Check It Out Now
LV9 Veteran (Next: 1337)

Offline

Gender:
Last Login: 20 May, 2013, 05:36:22
Date Registered: 02 May, 2011, 00:56:28
Location: Utah Valley
Posts: 1114

Topic starter
Total Post Ratings: +121

 « Reply #27 on: 22 February, 2012, 03:09:57 » 0

Explain how to do stuff with dot products? (I've never even heard of them)
 Logged

Completed Projects:
>> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
>> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.

Spoiler for Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)

Builderboy
Physics Guru

Offline

Gender:
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642

Total Post Ratings: +589

 « Reply #28 on: 22 February, 2012, 03:51:21 » 0

If you have two vectors A and B, the dot product returns this computation:

 1 Dot(A,B) = Mag(A)*Mag(B)*Cos(Angle between A and B).

Not only is this an interesting and potentially useful value, the dot product can also be calculated using simple multiplication and addition:

 1 Dot(A,B) = Ax*Bx + Ay*By

Roughly speaking, the dot product returns how much the vectors point in the same direction.  If the vectors point in the exact same direction, the result will be positive.  If the vectors are at right angles to each other, the dot product will return zero.  And if the vectors are pointing in opposite directions, the dot product will return a negative number.
 Logged

 Pages: 1 [2]   Go Up