Sea simulation
In junior high school maths, there are usually questions about measuring the angle of depression and/or distance using trigonometry. Common examples could be like "Find the angle of depression from a lighthouse beacon 112 m above the sea level to a boat that is at a horizontal distance of 1.5 km from the lighthouse". A picture (not to scale) may be given as the one on the right. But then, what if the scenario is in 3D?
So, it will be interesting to create a 3D virtual scene for this, and below is what I did.
And here is the Logo program.
; sea surface simulation ; by Andy CLEAN HOME RESET SETBG 47 WEST 36 NORTH 36 SETSCALE 8 1.5 8 ELEGRID MAKE "h1 WORDTOLIST GET WORD OBJECT "_elegrid "height ELEGRID MAKE "h2 WORDTOLIST GET WORD OBJECT "_elegrid "height DELETE OBJECT SELECT "obj_0 SETIT 4 21 DESELECT SETSCALE 1 1 1 HOME LT 45 RD 60 (DIRLIGHT {intensity:0.2}) TIMESENSOR "ts 6 TRUE VECINT "vi [0 .5 1] (LIST :h1 :h2 :h1) ROUTE "r1 "ts "fraction_changed "vi "set_fraction ROUTE "r2 "vi "value_changed "obj_0_elegrid "set_height HOME UP 1 SETSCALE 5 1 5 BOX UP 2 SETSCALE 2 4 2 CAN UP 2.5 SETSCALE .1 1 .1 REPEAT 8 [ FD 0.95 CAN BK 0.95 RT 45 ] UP 0.5 SETSCALE 1 1 1 DISH SETSC 1000 1000 0 DN 0.5 BALL TRANSFORM MAKE "light OBJECT SETPARENT :light FD 1 RT 180 (SPOTLIGHT {radius:0.8}) RT 180 BK 1 (SPOTLIGHT {radius:40,cutoffangle:1}) SPIN :light "lt 60 SETPARENT "root HEADLIGHTOFF HOME RESET BK 10 UP 1 WORLD "/sites/default/files/user/u3/world/boat.x3d LT 45 FD 15 WORLD "/sites/default/files/user/u3/world/boat.x3d RT 90 FD 25 WORLD "/sites/default/files/user/u3/world/boat.x3d ; create views (VIEWPOINT [POSITION: 1.9986 5.2234 5.4788, ORIENTATION: 0.0293 0.9991 -0.0295 0.402, centerofrotation: 7.0711 1 -18.2843]) GOTO "tower OBJECT CLICK "obj_14 "tower (VIEWPOINT [POSITION: -14.8981 2.0162 -2.1795, ORIENTATION: 0.0316 -0.9989 0.0343 1.9809, centerofrotation: 7.0711 1 -18.2843]) GOTO "ship1 OBJECT CLICK "obj_19 "ship1 (VIEWPOINT [POSITION: -4.111 2.1253 15.2682, ORIENTATION: 0.0112 -0.9976 0.0686 0.6659, centerofrotation: 7.0711 1 -18.2843]) GOTO "ship2 OBJECT CLICK "obj_18 "ship2 (VIEWPOINT [POSITION: 3.5393 2.9464 -15.3547, ORIENTATION: -0.2735 -0.9618 0.0114 0.9783, centerofrotation: 7.0711 1 -18.2843]) GOTO "ship3 OBJECT CLICK "obj_20 "ship3 ; showall
As can be seen in the codes, I included some viewpoints and behavious, so try to click on those boat to animate to soem viewpoints.
- Andy's blog
- Login or register to post comments
- 8026 reads