Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Creating angle/radius tables
2006-08-21 07:34
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Creating angle/radius tables

Is there a size-optimized way of getting a angle and radius table? It's easy enough to just precalc like this (pseudocode):

for(int x=0;x<w;x++)
{
for(int y=0;y<h;y++)
{
radius[tab]=sqrt((x-w/2)*(x-w/2)+(y-h/2)*(y-h/2));
angle[tab]=atan2(y-h/2,x-w/2)/PI);
tab++;
}
}

But what if you don't want to have the whole table precalced due to size concerns? Can you save space with some smart mirrortricks, etc.?
2006-08-21 07:42
Krill

Registered: Apr 2002
Posts: 2980
Have a look at the source code of this:

Artefacts

(i.e., mainly math.s in the source directory),
for some ideas on how to have radius and angle tables the size-optimized way.
2006-08-21 07:49
Style

Registered: Jun 2004
Posts: 498
dont be lame, calc them on the fly!

:D
2006-08-21 08:41
Oswald

Registered: Apr 2002
Posts: 5094
use basic :D
2006-08-21 21:17
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Thanks Krill, didn't remember that you had released the source to that amazing 4k, I will have to study that sometime!

Anyway, I sat down and thought it through some more, and the simple thing to do is to just do a mirror/flip with the four quadrants, thus only needing 1/4 of the table precalced, which saves enough space for now.
Perhaps it would be possible to get by with only one octant precalced, but I'm not going to pursue that right now.
2006-08-22 06:09
Style

Registered: Jun 2004
Posts: 498
Quote: Thanks Krill, didn't remember that you had released the source to that amazing 4k, I will have to study that sometime!

Anyway, I sat down and thought it through some more, and the simple thing to do is to just do a mirror/flip with the four quadrants, thus only needing 1/4 of the table precalced, which saves enough space for now.
Perhaps it would be possible to get by with only one octant precalced, but I'm not going to pursue that right now.


Never study other people's source - it spoils the fun!
2006-08-22 06:40
Oswald

Registered: Apr 2002
Posts: 5094
lol, style, u wrong.

DO STUDY other ppl code, then you know if you can do it better, and u dont have to reinvent the wheel:)

edit: I really wonder how much time would it took for one single man to reinvent everything since 82 :D
2006-08-22 06:45
Style

Registered: Jun 2004
Posts: 498
Ive never looked at other people's code, except for example routines in assembler books and a couple of routines Quetzal sent me once to explain how he did something (VSP from memory).

I like talking theory about how stuff works, but to actually look at code seems like cheating to me :)
2006-08-22 08:02
Jetboy

Registered: Jul 2006
Posts: 337
Quote: Ive never looked at other people's code, except for example routines in assembler books and a couple of routines Quetzal sent me once to explain how he did something (VSP from memory).

I like talking theory about how stuff works, but to actually look at code seems like cheating to me :)


O_O
Theory?
Do you think there were ANY theories avaliable back in the 80's?
The only theory you could get then was from examining other people's code.

Bah! Spoiled childs of the internet...
2006-08-22 08:04
JackAsser

Registered: Jun 2002
Posts: 2014
The early 80's was experimenting, the late 80's knew what they where doing with the HW imo.
2006-08-22 08:06
Jetboy

Registered: Jul 2006
Posts: 337
with what?
2006-08-22 08:08
JackAsser

Registered: Jun 2002
Posts: 2014
For instance insane multiplexers, maximzing the number of $d020 splits... FLDs, FPPs, sprite stretching etc. etc. I really doubt the best VIC-coders back then ripped code and only applied trial and error etc. They created their own theories and models imo. Brainers usually does that, where as lamers don't.
2006-08-22 09:30
Style

Registered: Jun 2004
Posts: 498
only teh lam0rxz rip!

Im a shit coder, but at least everything Ive written is mine alone.
2006-08-22 09:32
Oswald

Registered: Apr 2002
Posts: 5094
Jack, I think they looked at the vic as a black box, if I do this then this will come out and so on. they barely could have ideas of inner counters and stuff.

fpp fld etc.. you dont need to have much idea about it. its enough to know the sequence of the numbers to write to d011 and the right cycle. Again, it can work like a black box without deeper vic knowledge.


IMHO :)
2006-08-22 09:39
Oswald

Registered: Apr 2002
Posts: 5094
Quote: only teh lam0rxz rip!

Im a shit coder, but at least everything Ive written is mine alone.


hahaha, then every good coder is a lam0rxz :-)

I dont mean byte by byte ripping man, but you can get a general idea about the algorythm and tricks if u look at ones code, and most of the time you can find stuff to improve. Then you write ur own and better code from scratch. If u are an experienced coder there's not much things under the sun to steal, coz u know all the tricks anyway.

These days, (altho its happening now very rarely) I check the code to see what method was used, and how good was it done. Often its hard to say how fast this or that would be, but if you find a demo using a similar effect, then u might peek the code and get an idea of the code-onscreenspeed ratio.
2006-08-22 10:53
Jetboy

Registered: Jul 2006
Posts: 337
Tere is quite a difference between peeking at someones code, and reimplementing it your way, and just plain ripping.

There were no sources in the 80's/early 90's to learn from. All you had back then was C64 Refernece Guide. If you wanted to get some knowledge, the only way was peeking at someone else's code, or reinvent the wheel yourself.

There was much more learning in analyzing other's code in action replay's monitoe, than plain reading article on the internet and looking through clean sourcecode.

If one person was to invent everything we know now oneself, without external input, it would take that person couple tens of years, or more likely couple hundreds.

Articles explaining different theories were invention of the nineties. Earlier if you could find some codes in c64er or similar magazines there were mainly codes without too much proper explanations, beside, those were in german - so hardly readable to people who dont speak the language of Goethe.
2006-08-22 11:17
chatGPZ

Registered: Dec 2001
Posts: 11386
Quote:
There was much more learning in analyzing other's code in action replay's monitoe, than plain reading article on the internet and looking through clean sourcecode.


word! and i would recommend everyone who wants to learn coding to sit down and study some simple stuff (like crack intros for example), modify them, rip them apart, try to understand what this or that is doing. everyone did it like that back then, and you certainly can learn a lot from it.
2006-08-22 13:59
Copyfault

Registered: Dec 2001
Posts: 478
I can understand Styles point of view: me didn't peek through others code either. When I was younger I also thought it would be lame to look at other people's code, but this idea has fainted away...

Nowadays I do not find enough time (or am too mf lazy) to _seriously_ look through other's code; guess this explains why I didn't release anything yet, though my head is full of "ideas". Hopefully someone (something) forces me to release something somewhen...
2006-08-22 14:33
Jetboy

Registered: Jul 2006
Posts: 337
still i wonder what HW means...
2006-08-22 14:39
enthusi

Registered: May 2004
Posts: 677
hardware as opposed to SW ;)
2006-08-22 17:49
Slammer

Registered: Feb 2004
Posts: 416
Shadow: You only need to store 1/8 of the table if you mirror the quadrant. In your quadrant table you only need to store values where y<=x since radius(x,y) = radius(y,x) and angle(x,y)= 90-angle(y,x). (NB. I move the centre of the coordinate system to make the formulas simpler)

Never looking at other people’s code strengthens your creativity, since you always have to come up with a solution yourself. However, when you have found a solution that suits your needs, you don’t go looking for something better. If you do look at other people’s code, you are forced to understand the programmers way of solving things and thereby see other ways of solving things that your own.

I have met programmers who can only solve problems if they have seen a solution for a similar problem in advance. However, if you newer look at other peoples code your might be doing very basic things in an unnecessary difficult way because you never stumbled upon the elegant solution yourself. So there are pros and cons of both approaches.
2006-08-22 18:31
tlr

Registered: Sep 2003
Posts: 1790
Reusing knowledge/looking at other peoples solutions before not doing it the same way yourself is the mother of all invention IMO.

Who wants to start understanding how to make paper so they have something to write down their self thought up version of calculus for instance?

I find avoiding looking at other people's code, but still using other people's math a bit inconsistent.

Progress is iterative...
2006-08-22 19:26
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Slammer : Thanks, there is that octant mirroring I was going on about. The only drawback is that get a somewhat more complex mirroring since you are not dealing with square blocks anymore.

To chime in on the looking-at-other-peoples-source-debate:
When I started in the eighties, it was just about the only way to find out how stuff was done (atleast for me a fourteen year old kid not smart enough to come up with the VIC-timing stuff by myself :)). It was considered a bit "lame" though as I recall it, but I think almost all coders did it.
2006-08-23 05:12
Style

Registered: Jun 2004
Posts: 498
Ur 411 t3h l4m3!!

1 2u1+ t3h 5c3N3!!!!!!

:)
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Andy/AEG
Alta
MWR/Visdom
rambo/Therapy/ Resou..
Icon/TRIAD
cba
Guests online: 123
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.058 sec.