'cdg 1.03 (c) Jose Angel Gonzalez Rodriguez
'Noviembre de 1997 November 1997
'Creado con QuickBasic 4.5 Created with QuickBasic 4.5
'Compilado con PBasic 3.1 Compiled with PBasic 3.1
DECLARE SUB CDG3
(x1!
, x2!
, x3!
, x4!
, y1!
, y2!
, y3!
, y4!
, z1!
, z2!
, z3!
, z4!
, cont%
, col
) DECLARE SUB CDG2
(x1!
, x2!
, x3!
, y1!
, y2!
, y3!
, z1!
, z2!
, z3!
, cont%
, col
) DECLARE SUB cdg
(x1!
, x2!
, x3!
, x4!
, y1!
, y2!
, y3!
, y4!
, z1!
, z2!
, z3!
, z4!
, cont
)
blanco = 15
negro = 0
pi! = 3.141592
paso! = pi! / 32
D3 = 0
D2 = 1
NIter = 3
py = 19
yy = py
ArMin! = 0
NVert = 4
pot! = 3
dist! = 1
r! = 640 / 480
blue = 56: green = 63: red = 13
ColorNumber& = 65536 * blue + 256 * green + red
'PALETTE 15, ColorNumber&
Empezar:
NVert = 4
VertXY!(1, 1) = .4926414
VertXY!(2, 1) = .54941
VertXY!(3, 1) = -.1704186
VertXY!(4, 1) = -.8716328
VertXY!(1, 2) = -.5649168
VertXY!(2, 2) = .804424
VertXY!(3, 2) = -.5311065
VertXY!(4, 2) = .2915995
VertXY!(1, 3) = .6619467
VertXY!(2, 3) = -.2259439
VertXY!(3, 3) = -.82999
VertXY!(4, 3) = .3939873
NVert = 3
VertXY!(1, 1) = .5877291
VertXY!(2, 1) = -.8816133
VertXY!(3, 1) = .2938841
VertXY!(1, 2) = -.4518031
VertXY!(2, 2) = -.4036101
VertXY!(3, 2) = .8554131
VertXY!(1, 3) = .6711546
VertXY!(2, 3) = -.2446566
VertXY!(3, 3) = -.426498
Arriba
Izquierda
Redibuja:
REM para saltar si es estable:
Mensajes
Dibujar:
Redi:
DibuFrame
CogeTecla
DibuCDG3 blanco
DibuCDG2 blanco
'Girando = 0
IntroduceCaracter:
DibuNegro
alfa!
= ATN(VertXY!
(i
, 2) / SQR(VertXY!
(i
, 3) ^ 2 + VertXY!
(i
, 1) ^ 2)) beta!
= ATN(VertXY!
(i
, 1) / VertXY!
(i
, 3)) + paso!
VertXY!
(i
, 2) = SIN(alfa!
) VertXY!
(i
, 1) = SGN(VertXY!
(i
, 3)) * COS(alfa!
) * SIN(beta!
) VertXY!
(i
, 3) = SGN(VertXY!
(i
, 3)) * COS(alfa!
) * COS(beta!
) DibuNegro
alfa!
= ATN(VertXY!
(i
, 2) / SQR(VertXY!
(i
, 3) ^ 2 + VertXY!
(i
, 1) ^ 2)) beta!
= ATN(VertXY!
(i
, 1) / VertXY!
(i
, 3)) - paso!
VertXY!
(i
, 2) = SIN(alfa!
) VertXY!
(i
, 1) = SGN(VertXY!
(i
, 3)) * COS(alfa!
) * SIN(beta!
) VertXY!
(i
, 3) = SGN(VertXY!
(i
, 3)) * COS(alfa!
) * COS(beta!
) DibuNegro
alfa!
= ATN(VertXY!
(i
, 1) / SQR(VertXY!
(i
, 2) ^ 2 + VertXY!
(i
, 3) ^ 2)) beta!
= ATN(VertXY!
(i
, 3) / VertXY!
(i
, 2)) + paso!
VertXY!
(i
, 1) = SIN(alfa!
) VertXY!
(i
, 3) = SGN(VertXY!
(i
, 2)) * COS(alfa!
) * SIN(beta!
) VertXY!
(i
, 2) = SGN(VertXY!
(i
, 2)) * COS(alfa!
) * COS(beta!
) DibuNegro
alfa!
= ATN(VertXY!
(i
, 1) / SQR(VertXY!
(i
, 2) ^ 2 + VertXY!
(i
, 3) ^ 2)) beta!
= ATN(VertXY!
(i
, 3) / VertXY!
(i
, 2)) - paso!
VertXY!
(i
, 1) = SIN(alfa!
) VertXY!
(i
, 3) = SGN(VertXY!
(i
, 2)) * COS(alfa!
) * SIN(beta!
) VertXY!
(i
, 2) = SGN(VertXY!
(i
, 2)) * COS(alfa!
) * COS(beta!
) Girando = 1
Pitido1
NIter = NIter + 1
DibuNegro
Pitido1
NIter = NIter - 1
DibuNegro
D2 = 1: D3 = 0
DibuNegro
D2 = 0: D3 = 1
SalidaOK
'GOTO ReDibuja
alfa!
= ATN(VertXY!
(i
, 1) / SQR(VertXY!
(i
, 2) ^ 2 + VertXY!
(i
, 3) ^ 2)) beta!
= ATN(VertXY!
(i
, 3) / VertXY!
(i
, 2)) + a!
VertXY!
(i
, 1) = SIN(alfa!
) IF VertXY!
(i
, 2) > 0 THEN VertXY!
(i
, 3) = COS(alfa!
) * SIN(beta!
) ELSE VertXY!
(i
, 3) = -COS(alfa!
) * SIN(beta!
) IF VertXY!
(i
, 2) > 0 THEN VertXY!
(i
, 2) = COS(alfa!
) * COS(beta!
) ELSE VertXY!
(i
, 2) = -COS(alfa!
) * COS(beta!
)
SUB CDG2
(x1!
, x2!
, x3!
, y1!
, y2!
, y3!
, z1!
, z2!
, z3!
, cont
, col
)
xc! = (x1! + x2! + x3!) / 3
yc! = (y1! + y2! + y3!) / 3
zc! = (z1! + z2! + z3!) / 3
LINE (x1!
, y1!
)-(xc!
, yc!
), col
LINE (x2!
, y2!
)-(xc!
, yc!
), col
LINE (x3!
, y3!
)-(xc!
, yc!
), col
CDG2 x1!, x2!, xc!, y1!, y2!, yc!, z1!, z2!, zc!, cont - 1, col
CDG2 x1!, xc!, x3!, y1!, yc!, y3!, z1!, zc!, z3!, cont - 1, col
CDG2 xc!, x2!, x3!, yc!, y2!, y3!, zc!, z2!, z3!, cont - 1, col
SUB CDG3
(x1!
, x2!
, x3!
, x4!
, y1!
, y2!
, y3!
, y4!
, z1!
, z2!
, z3!
, z4!
, cont
, col
)
xc! = (x1! + x2! + x3! + x4!) / 4
yc! = (y1! + y2! + y3! + y4!) / 4
zc! = (z1! + z2! + z3! + z4!) / 4
LINE (x1!
, y1!
)-(xc!
, yc!
), col
LINE (x2!
, y2!
)-(xc!
, yc!
), col
LINE (x3!
, y3!
)-(xc!
, yc!
), col
LINE (x4!
, y4!
)-(xc!
, yc!
), col
CDG3 x1!, x2!, x3!, xc!, y1!, y2!, y3!, yc!, z1!, z2!, z3!, zc!, cont - 1, col
CDG3 x1!, x2!, xc!, x4!, y1!, y2!, yc!, y4!, z1!, z2!, zc!, z4!, cont - 1, col
CDG3 x1!, xc!, x3!, x4!, y1!, yc!, y3!, y4!, z1!, zc!, z3!, z4!, cont - 1, col
CDG3 xc!, x2!, x3!, x4!, yc!, y2!, y3!, y4!, zc!, z2!, z3!, z4!, cont - 1, col
x1! = VertXY!(1, 1)
x2! = VertXY!(2, 1)
x3! = VertXY!(3, 1)
y1! = VertXY!(1, 2)
y2! = VertXY!(2, 2)
y3! = VertXY!(3, 2)
z1! = VertXY!(1, 3)
z2! = VertXY!(2, 3)
z3! = VertXY!(3, 3)
CDG2 x1!, x2!, x3!, y1!, y2!, y3!, z1!, z2!, z3!, NIter, col
x1! = VertXY!(1, 1)
x2! = VertXY!(2, 1)
x3! = VertXY!(3, 1)
x4! = VertXY!(4, 1)
y1! = VertXY!(1, 2)
y2! = VertXY!(2, 2)
y3! = VertXY!(3, 2)
y4! = VertXY!(4, 2)
z1! = VertXY!(1, 3)
z2! = VertXY!(2, 3)
z3! = VertXY!(3, 3)
z4! = VertXY!(4, 3)
CDG3 x1!, x2!, x3!, x4!, y1!, y2!, y3!, y4!, z1!, z2!, z3!, z4!, NIter, col
negro = 0
LINE (f!
(i
, 1), f!
(i
, 2))-(f!
(j
, 1), f!
(j
, 2)), negro
LINE (VertXY!
(i
, 1), VertXY!
(i
, 2))-(VertXY!
(j
, 1), VertXY!
(j
, 2))
f!(i, 1) = VertXY!(i, 1)
f!(i, 2) = VertXY!(i, 2)
f!(j, 1) = VertXY!(j, 1)
f!(j, 2) = VertXY!(j, 2)
negro = 0
LINE (f!
(i
, 1), f!
(i
, 2))-(f!
(j
, 1), f!
(j
, 2)), negro
DibuFrameNegro
negro = 0
DibuCDG3 negro
DibuCDG2 negro
SUB EscapeParaSalir
(Lin
) Resalta "Esc para salir", 3
PRINT "-----------------------------------------------------------------------------";
LineaEspanol
PRINT "Dibujemos un triangulo y su Centro De Gravedad." PRINT "Tracemos lineas desde este C.D.G. hasta los vertices del" PRINT "triangulo. Si hacemos lo mismo con los 3 nuevos triangulos" PRINT "que se forman y obramos asi sucesivamente, conseguimos este fractal." PRINT "Si lo hacemos con tetraedros conseguimos la version tridimensional." PRINT "-----------------------------------------------------------------------------";
LineaIngles
PRINT "Let us draw a triangle and its Centre Of Gravity." PRINT "Then we draw lines from this C.O.G to the vertex of the" PRINT "triangle. If we do the same with the 3 new triangles and so on," PRINT "we get this fractal." PRINT "We can get it in 3-Dimensions if we do it with tetrahedrons." PRINT "-----------------------------------------------------------------------------";
PRINT "Sugerencias: FidoNet 2:344/18.8 -- Correo: Jose Angel Gonzalez" PRINT " Capuchinos, 9 - 6 C " PRINT "E-Mail: jgonzalezr@nexo.es 31500 Tudela (Navarra) SPAIN";
alfa!
= ATN(VertXY!
(i
, 2) / SQR(VertXY!
(i
, 3) ^ 2 + VertXY!
(i
, 1) ^ 2)) beta!
= ATN(VertXY!
(i
, 1) / VertXY!
(i
, 3)) + a!
VertXY!
(i
, 2) = SIN(alfa!
) IF VertXY!
(i
, 3) > 0 THEN VertXY!
(i
, 1) = COS(alfa!
) * SIN(beta!
) ELSE VertXY!
(i
, 1) = -COS(alfa!
) * SIN(beta!
) IF VertXY!
(i
, 3) > 0 THEN VertXY!
(i
, 3) = COS(alfa!
) * COS(beta!
) ELSE VertXY!
(i
, 3) = -COS(alfa!
) * COS(beta!
)
N = 3
LOCATE N
, 1:
PRINT "Con + / - se cambia la densidad del fractal. Con las flechas puede girar.";
N = 13
PRINT "With + / - you change the fractal's density. With arrows, you rotate it.";
SHARED py
, colorres
, colornormal
, NIter
, L1$
, L2$
py = 28: colorres = 14: colornormal = 7
LOCATE 3, 65: Resalta
"F1: Help", 2 LOCATE 30, 67: Resalta
"Esc to exit", 3
Info