[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> RE: 3D Logo source ?



Jean-Paul Roy wrote:
> 
> A friend of mine [physicist] wants for his son the source of a 3D
> package for Logo. He uses a Logo with only 2D commands, and would
> like to pilot a turtle in 3D-space with plane-like commands : yaw,
> pitch, and roll to draw a line solid.
> Does anybody have a pointer on *portable* pure Logo source for that ?
> Thanks a lot,
>                      Jean-Paul Roy


I think the attachment is, more or less, what Jean-Paul is searching
for.

A notice: I' ve seen some posting talking of a 3-D logo in which PITCH
and PULLUP are substituted by UP :degrees and DOWN :degrees. As has been
noted, this can cause confusion with PENUP and PENDOWN. The airplane
metaphore saves the virtual meaning of the latter commands. YAW could be
obtained modifying the meaning of RT and LT, but IMHO I think it is
better to use different commands when working in 3-D. Again IMHO, i
think that ROLL, though obtainable wint combitations of UP, DOWN, RT and
LT, is far more intuitive.
 
Ciao
----------------------
Tommaso RUSSO
Abitazione: 
  Strada per Longera 4/1 I-34128 Trieste
  +39(40)568.777
  trusso@tin.it
Ufficio:
  Responsabile Progetto Reti - AREA Science Park
  Padriciano 99 I-34012 Trieste
  +39(40)375.5259 
  Tommaso.Russo@Area.Trieste.It
TO AAAREADME
; Copyright (C) 1993 Tommaso RUSSO,  AREA Science Park, Trieste, Italy
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation Inc., 675 Mass Ave, Cambridge, MA 02139
; USA - current version.
;
; WARNING: this version works with ucblogo and mswlogo. 
;          For LCSI logo, modify CABRA and VIRA and strip out comments.
;
; This software was written to implement an idea of Horacio C. Reggini read in
; "Computadores: Creativitad o automatismo?", 
; Ediciones Galapago, Buenos Aires, 1988.
; 
; The basic idea is that "any solid body can be described showing, starting
; from a point, all the movements needed to run on all its edges". To do so,
; the classical turtle is modified so that it can takeoff, i.e. pullup, and
; then yaw, pitch and roll. 
;
; As far I know, Reggini implemented the same or similar commands as primitives
; and left to a graphic workstation the task of projecting the obtained
; solids onto a plane by variuos perspectives.
;
; This version is written in LOGO (ucb/mswlogo: LCSI logo requires a minor
; change) and the projection is pure axonometry from the z-axis.
;
; The command needed to initialize the three versors that individuate the
; flying turtle in the space is HANGAR. HANGAR can be used also as a 3-d
; HOME command. The other commands are GO (equivalent to forward, but in the
; 3d space), YAW, PITCH,(PULLUP) and ROLL (whose input is an angle in degrees).
; Yaw with a positive argument turns clockwise (compass convention, as RIGHT),
; Roll also turns clockwise.
; All the commands accept negative arguments.
;
; HOME, FD, BK, RT and LT can still be used, but carefully.
;
; Reggini wrote its commands in spanish: I did it first in italian. The
; equivalences between the commands are:
;
;      Espanol              Italiano               English
;
;        ?                  hangar                 hangar
;      andar                vai                    go
;      cabecear             picchia                pitch
;        ?                  cabra                  pullup
;      virar                vira                   yaw
;      rolar                rolla                  roll
;
; Only one out of PITCH and PULLUP is needed. The reason why both are
; defined is that Reggini finds natural to use CABECEAR (probably thinking
; of the movements of an hand), while CABRA seems more natural to me (thinking
; to an airplane).
;
; Try it: load this file and type TAKEOFF.
;
; This text written on nov. 24, 1993
;
EDIT "AAAREADME
END

TO HANGAR
IF NOT NAMEP "PRX [FSFLICENSE]
; PR stands for PRUA (bow)
; AD stands for ALA DESTRA (rigth wing)
; SU stands for SU (up; zenith)
MAKE "PRX 0  MAKE "PRY 1 MAKE "PRZ 0
MAKE "ADX 1  MAKE "ADY 0 MAKE "ADZ 0
MAKE "SUX 0  MAKE "SUY 0 MAKE "SUZ 1
HOME
END

TO FSFLICENSE
PRINT [Copyright (C) 1993 Tommaso RUSSO, AREA Science Park, Trieste, Italy]
PRINT [This program is free software\; you can redistribute it and/or modify]
PRINT [it under the terms of the GNU General Public License as published by]
PRINT [the Free Software Foundation Inc., 675 Mass Ave, Cambridge, MA 02139]
PRINT [USA - current version.]
PRINT [This version for ucblogo/mswlogo. For LCSI logo, modify CABRA and VIRA]
WAITAKEY
END

TO WAITAKEY
PRINT [\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  Press any key to continue]
IGNORE READCHAR
CLEARTEXT
END

TO CABRA :FI
MAKE "COSFI COS :FI
MAKE "SINFI SIN :FI
MAKE "SUNEWX :SUX * :COSFI - :PRX * :SINFI
MAKE "SUNEWY :SUY * :COSFI - :PRY * :SINFI
MAKE "SUNEWZ :SUZ * :COSFI - :PRZ * :SINFI
MAKE "PRX :PRX * :COSFI + :SUX * :SINFI
MAKE "PRY :PRY * :COSFI + :SUY * :SINFI
MAKE "PRZ :PRZ * :COSFI + :SUZ * :SINFI
MAKE "SUX :SUNEWX
MAKE "SUY :SUNEWY
MAKE "SUZ :SUNEWZ
; please note: ucblogo and mswlogo use (arctan x y), while LCSI logo
; uses (arctan y x).
; the following line works with ucblogo (x and y are exchanged because
; setheading counts starting from y axis clockwise), but
; should be modified for lcsi logo.
IF NOT AND EQUALP :PRX 0 EQUALP :PRY 0 [SETHEADING (ARCTAN :PRY :PRX)]
END

TO PICCHIA :FI
CABRA -:FI
END

TO ROLLA :FI
MAKE "COSFI COS :FI
MAKE "SINFI SIN :FI
MAKE "SUNEWX :SUX * :COSFI + :ADX * :SINFI
MAKE "SUNEWY :SUY * :COSFI + :ADY * :SINFI
MAKE "SUNEWZ :SUZ * :COSFI + :ADZ * :SINFI
MAKE "ADX :ADX * :COSFI - :SUX * :SINFI
MAKE "ADY :ADY * :COSFI - :SUY * :SINFI
MAKE "ADZ :ADZ * :COSFI - :SUZ * :SINFI
MAKE "SUX :SUNEWX
MAKE "SUY :SUNEWY
MAKE "SUZ :SUNEWZ
END

TO VIRA :FI
MAKE "COSFI COS :FI
MAKE "SINFI SIN :FI
MAKE "PRNEWX :PRX * :COSFI + :ADX * :SINFI
MAKE "PRNEWY :PRY * :COSFI + :ADY * :SINFI
MAKE "PRNEWZ :PRZ * :COSFI + :ADZ * :SINFI
MAKE "ADX :ADX * :COSFI - :PRX * :SINFI
MAKE "ADY :ADY * :COSFI - :PRY * :SINFI
MAKE "ADZ :ADZ * :COSFI - :PRZ * :SINFI
MAKE "PRX :PRNEWX
MAKE "PRY :PRNEWY
MAKE "PRZ :PRNEWZ
; please note: ucblogo and mswlogo use (arctan x y), while LCSI logo
; uses (arctan y x).
; the following line works with ucblogo (x and y are exchanged because
; setheading counts starting from y axis clockwise), but
; should be modified for lcsi logo.
IF NOT AND EQUALP :PRX 0 EQUALP :PRY 0 [SETHEADING (ARCTAN :PRY :PRX)]
END

TO VAI :DIST
FD :DIST * SQRT(:PRX*:PRX +:PRY*:PRY)
END

TO YAW :ANG
VIRA :ANG
END

TO ROLL :ANG
ROLLA :ANG
END

TO PITCH :ANG
CABRA -:ANG
END

TO PULLUP :ANG
CABRA :ANG
END

TO GO :DIST
VAI :DIST
END

TO SQ :L
REPEAT 4 [VAI :L VIRA 90]
END

TO CUBE :L
REPEAT 4 [SQ :L YAW 90 GO :L YAW -90  ROLL -90]
END

TO PALETAS :L
REPEAT 9 [SQ :L ROLL 40]
END 

TO FRANJA :L
PENUP GO -:L/2 PENDOWN
REPEAT 2 [GO :L VIRA 90 GO :L/8 VIRA 90]
PENUP GO :L/2 VIRA 90 GO :L/8 VIRA -90 PENDOWN
END

TO ANILLO :L
REPEAT 45 [FRANJA :L ROLL -8]
END

TO MOEBIUS :L
LOCAL "ANG
MAKE "ANG 0
REPEAT 45 [PITCH :ANG FRANJA :L PITCH -:ANG ROLL -8 MAKE "ANG :ANG + 4]
END

TO TAKEOFF
HANGAR
PRINTANDRUN [HANGAR CS PICCHIA 70 VIRA 30 ROLLA 12 CUBE 100]
WAITAKEY
PRINTANDRUN [HANGAR CS CABRA 30 ROLLA 12 PALETAS 100]
WAITAKEY
PRINTANDRUN [HANGAR CS CABRA 12 ANILLO 128]
WAITAKEY
PRINTANDRUN [HANGAR CS CABRA 12 MOEBIUS 128]
WAITAKEY
PRINT [Try by yourself modifying the starting angles. Enjoy!]
END

TO PRINTANDRUN :LIST
PRINT :LIST
RUN :LIST
END





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