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 > accurate 3d rotation
2013-05-22 12:12
Oswald

Registered: Apr 2002
Posts: 5094
accurate 3d rotation

some silly questions & a lot of text here, its been ages I have done this routine and I am wondering where could I find more accuracy.

I am using the additive method to get the rotation matrix, working with 16 bit sines.

first, I wonder why have I choosen the sinetable max value to be +/- $1fff, there's no consecutive 4 adc's to have overflow over +/- $8000, still an adc / sbc pair may turn into adc/adc because of the case when substracting a negative number? :/ not sure if sine lookups may align this way. also should I round the 16 bit table or those bits will go bad anyway? (dont remember if I have rounded it, boy its been precalculated in basic in the stone ages:)

secondly, I keep adding #$40 to rotation angles in many places before looking them up in sincos tables. I suspect I am doing something wrong here, trying to turn the lookup value into cosine, while still having a label for the cosine offset. sin+$40= cosine, cosine+(angle+#$40)= ??? why ? :D or does this thing come from the sin*cos to addition theoremes?

third: if I recall right each adc/sbc introduces 1 bit error, is this true? so after 2 adc lowmost 2 bits in the 16 bit result is unusable?

fourth: flipping sign of a 2 complement 16 bit number is this correct?:

	lda yxl    ;*-1
	eor #$ff
	clc
	adc #$01
	sta yxl

	lda yxh
	eor #$ff
	adc #$00
	sta yxh


finally, getting a cube coordinate out of the rotation matrix, only using the HI bytes:

	lda xzh    ;mpp
	clc
	adc xyh
	sec
	sbc xxh
	sta vertexes+0


should I rewrite this to gain accuracy including the low 8 bits?:

        lda xzl
        clc
        adc xyl
        sta templ
        
        lda xzh
        adc xyh
        sta temph
        ...
        etc


finally, rounding the final8 bits by looking at the low8 is a good idea? ie, if low8 (signless) msb is high, inc high8 bits?
 
... 20 posts hidden. Click here to view all posts....
 
2013-05-23 08:34
Oswald

Registered: Apr 2002
Posts: 5094
Quote: That's the square tables for babylonian multiplication.

should made it clear in the article :)
2013-05-23 08:43
Bitbreaker

Registered: Oct 2002
Posts: 508
Quote: should made it clear in the article :)

Well, the articles base on each other, as the multiplication is used also during rotation and such. But it sure wouldn't hurt to add some comments to the code, yes :-)
2013-11-28 09:47
theWizard
Account closed

Registered: Jul 2007
Posts: 109
3d on a 64 , driller was wrong , 3d on a c64 should be illegal mate , it just looks wrong allways has allways will.
Previous - 1 | 2 | 3 - Next
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
DJ Gruby/TRiAD
Freeze/Blazon
MWR/Visdom
REBEL 1/HF
commodore_freak
Guests online: 93
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

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