Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:26 01 May 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMiteVGA DEMO

     Page 12 of 12    
Author Message
javavi

Guru

Joined: 01/10/2023
Location: Ukraine
Posts: 550
Posted: 04:49pm 26 Apr 2026
Copy link to clipboard 
Print this post

Rotating 2D sphere
with and without cache tracing

'Option TraceCache On 32

Const NumPoints = 500
Const Radius = 190
Const Dist = 500
Const X0 = MM.HRES\2
Const Y0 = MM.VRES\2

Dim x(NumPoints), y(NumPoints), z(NumPoints)
Dim angleX, angleY

For i=1 To NumPoints
phi=2*Pi*Rnd
theta=ACos(2*Rnd-1)
x(i)=Radius*Sin(theta)*Cos(phi)
y(i)=Radius*Sin(theta)*Sin(phi)
z(i)=Radius*Cos(theta)
Next

Colour RGB(Cyan)

Do
Inc angleX,.02
Inc angleY,.03
CLS : Print Timer: Timer =0

For i=1 To NumPoints
 ny=y(i)*Cos(angleX)-z(i)*Sin(angleX)
 nz=y(i)*Sin(angleX)+z(i)*Cos(angleX)
 nx=x(i)*Sin(angleY)+nz*Cos(angleY)

 finalZ=-x(i)*Sin(angleY)+nz*Cos(angleY)
 proj=dist/(dist-finalZ)
 Pixel X0+nx*proj,Y0+ny*proj
Next
Loop While Inkey$=""
 
     Page 12 of 12    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026