;input = (X,Y) on plane;output = Transformed pointGlobal resultx#, resulty#, resultz#Function PointOntoPlane(x#, y#, z#, nx#,ny#,nz#,d#) a# = 0 c# = ATan2(nx, ny) b# = ATan2(nz, Sqr(nx*nx+ny*ny)) ;apply pitch to point ix# = x iy# = (Cos(-b) * y) - (Sin(-b) * z) iz# = (Sin(-b) * y) + (Cos(-b) * z) ;apply roll to point jx# = (Cos(-a) * ix) - (Sin(-a) * iy) jy# = (Sin(-a) * ix) + (Cos(-a) * iy) jz# = iz ;apply plane offset resultx# = jx# - nx*d resulty# = jy# - ny*d resultz# = jz# - nz*dEnd Function;Resource: <a href="http://www.geocities.com/siliconvalley/2151/math3d.html" target="_blank">http://www.geocities.com/siliconvalley/2151/math3d.html</a>;------------------------------------------------------------------------------------------------------------------------------------; EXAMPLE;------------------------------------------------------------------------------------------------------------------------------------ ;setup 3D Graphics3D 800, 600, 0, 2 SetBuffer BackBuffer() ;create camera MoveEntity CreateCamera(), 0, 0, -5 Dim sph(9) ;create 10 spheres For i = 0 To 9 sph(i) = CreateSphere() ScaleEntity sph(i), 0.1, 0.1, 0.1 ;make sphere smaller EntityColor sph(i), 255, 0, 0 ;make sphere red Next ;basically, the plane is rotated around the y-axis ;and the spheres are places accordingly Repeat ;rotate plane angle = angle + 1 ;increase 'angle' nx# = Cos(angle) ;calculate normal = vector pointing forward from plane ny# = 0 nz# = Sin(angle) d# = 0 ;this is the distance of the plane from (0, 0, 0) ;place spheres For i = 0 To 9 x# = Cos(i * 36) ;calculate position of sphere in 2D space y# = Sin(i * 36) PointOntoPlane(x, y, 0, nx,ny,nz,d) ;transform position from 2D space to 3D space PositionEntity sph(i), resultx, resulty, resultz ;apply position Next RenderWorld Flip ;esc=exit Until KeyHit(1) End