| 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$="" |