to aaa
; This example truely covers the surface of a torus with each
; vertex of each polygon exactly on the surface with no overlaping
; polygons and letting logo do all the trig involved.
;
; This is easier to explain using a sphere as example.
; Place yourself in the center of a sphere and imagine you have
; a laser gun that can cut or mark the surface. Now you basically
; Shoot a dot on the surface (call that point A), then move your
; aim 5 degrees (:step) down, shoot another dot (call that point B).
; Now aim 5 degrees to the right, Shoot another dot (call that point
C).
; Now aim 5 degrees up, shoot another dot. Now connect the 4 dots
; with a string and you have your polygon. Get the idea.
;
; This does not quite work right on the sphere but does work
; perfectly on the torus.
perspective
cs
setsc [0 0 0]
ht
pu
; Time drawing
localmake "start timemilli
; This is the color of the OBJECT not the color you'll see
setpc [255 0 0]
Torus 150 75 5
; Display elapsed drawing
(print "Define (timemilli - :start) / 1000)
; Time shading
make "start timemilli
polyview
; Display elapsed shading
(print "Render (timemilli - :start) / 1000)
pd
end
to GetPoint :rad
fd :rad
localmake "pos posxyz
bk :rad
output :pos
end
to Slice :rad1 :rad2 :step
; Draw an open ended cylinder
localmake "i 0
repeat 360/:step ~
[
fd :rad1
down :i
localmake "PointA GetPoint :rad2
down :step
localmake "PointB GetPoint :rad2
up :step
up :i
bk :rad1
rt :step
fd :rad1
down :i
localmake "PointD GetPoint :rad2
down :step
localmake "PointC GetPoint :rad2
up :step
up :i
bk :rad1
lt :step
localmake "PointE posxyz
setposxyz :PointA
pd
polystart
setposxyz :PointB
setposxyz :PointC
setposxyz :PointD
setposxyz :PointA
polyend
pu
setposxyz :PointE
make "i :i + :step
]
end
to Torus :rad1 :rad2 :step
; Cover the surface of the torus with polygons
repeat 360/:step [Slice :rad1 :rad2 :step rt :step]
end
--
===============================================================
George Mills (mills@softronix.com)
http://www.softronix.com/
The www page contains some very powerful educational software.
Our single most important investment is our kids.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home