Library for drawing turtle type (Logo turtle)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Simulation mechanism of a connecting rod and a crank

Post by lrcvs »

Hi:

This experiment makes the simulation mechanism of a connecting rod and a crank.

Not to any calculation used trigonometry.

It is based on the color of the line of rail

regards

Code: Select all

#include "turtle_9.bi"
DIM AS DOUBLE j,k,m,n,x,x2,y,y2
CLS
t_init
t_thick = 1
FOR j = 1 TO 10
    FOR n = 0 TO 360
        SCREENLOCK
        CLS
        t_pos(150,0):t_distance_points = 0.1:t_or 0:t_ink 15:t_fd 400:t_ink 7
        t_pos(0,0):t_circle 5:t_ink 10:t_circle 100:t_ink 7:t_gt (x,y)
        x = COS(t_radians(n))*100
        y = SIN(t_radians(n))*100
        t_pos(x,y):t_ink 9:t_circle 5
        
        '  t_circle 299 '<<<<<< Activate
        
        FOR k = 0 TO 360 STEP 0.1
            x2 = COS(t_radians(k))*300+x
            y2 = SIN(t_radians(k))*300+y
            IF POINT(x2,y2) = 15 THEN
                t_or 0
                t_ink 12
                t_pos(x2,y2)
                t_fd 50
                t_lt 90
                t_fd 50
                t_lt 90
                t_fd 100
                t_lt 90
                t_fd 50
                t_lt 90
                t_fd 50                
                t_ink 9:t_pos(x,y):t_gt(X2,Y2+25):t_circle 5
            END IF
        NEXT k
        
        SCREENUNLOCK
        SLEEP 2
    NEXT n
NEXT j
PRINT "END"
SLEEP
END
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Series Mechanism, #2

Post by lrcvs »

Hi:

Other Simulation mechanism.

This is the number # 2



(Here begins a new series of mechanical movements simulation mechanisms.)


Code: Select all

#include "turtle_9.bi"
' Mechanism #2
DIM AS DOUBLE g,h, p,x2,y2

CLS
t_init
FOR p = 0 TO 5
    FOR g = 0 TO 360 STEP 0.5
        SCREENLOCK
        CLS
        t_distance_points = 5
        t_ink 2:t_pos (0,0):t_circle 100
        t_ink 3:t_pos (75,0):t_circle 150
        
        t_distance_points = 0.1
        t_ink 2:t_pos (0,0):t_circle 3
        t_ink 3:t_pos (75,0):t_circle 3
        
        t_ink 15
        t_pos (75,0)
        t_ol g
        t_fd 150
        
        FOR h = 0 TO 360 STEP 0.1
            x2 = COS(t_radians(h))*100
            y2 = SIN(t_radians(h))*100
            
            IF POINT(x2,y2) = 15 THEN
                t_ink 12
                t_pos (0,0)
                t_ol h
                t_fd 100
                t_ink 14
                t_circle 5
            END IF
            
        NEXT h
        
        SCREENUNLOCK
        SLEEP 0.6
        
    NEXT g
    
NEXT p
SLEEP
END
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Arc_rotatory

Post by lrcvs »

Hi:

Other Simulation mechanism:

Arc_rotatory


This is the number # 3

See you:

https://www.youtube.com/watch?v=EPoP60QRCaE

Code: Select all

#Include "turtle_9.bi"
Dim As Double h,n,x,y

'arc rotatory

Cls
t_init
For n = 3600 To 0 Step -1 'loops
	ScreenLock
	Cls
	
	'trajectories greens
	t_distance_points = 5
	t_thick = 0.1
	t_ink 10
	
	t_pos(0,0)
	t_circle 5
	t_circle 285 
	
	t_pos (-100,0)
	t_circle 5
	t_circle 250 
	't_circle 175
	
	'position and movements line white
	t_distance_points = 0.1
	t_ink 15
	t_thick = 2
	t_pos (0,0)
	t_rot_cir_l(200,n)
	t_curves (200,200,90,180,n,0)'arc
	
	For h = 0 To 360 Step 0.1
		x = (Cos(t_radians(h))*175)-100
		y = (Sin(t_radians(h))*175)
		If Point(x,y) = 15 Then 'detection point
			t_ink 12
			t_pos (-100,0)
			t_ol h
			t_fd 250 'line rotatory red
			t_ink 14
			t_pos (x,y)'position cursor yellow
			t_circle 5
		End If
	Next h
	
	ScreenUnlock
	Sleep 20
Next n
Sleep
End
Regards
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Hi

Mechanism of 4 bar of Grashof

Code: Select all

'program mechanism of 4 bar of Grashof
'lrcvs 15.05.16

#Include "turtle_9.bi"
Dim As double g,h,i,j,k,x2,px1,py1,px2,py2,n
Dim As Double l1,l2,l3,l4
Dim p1 (1800,2) As Double
Dim p2 (1800,2) As Double
'long 4 bars
l1 = 100 'bar 1 (distance axes line, imaginary bar )
l2 = 50 'bar 2 motor / emisor of movement
l3 = 120 'bar 3 (link bar)
l4 = 200'bar 4 receptor of movement 
g = 1
t_init
For n = 0 To 360 * 2 'loops
	k = 0
	For j = 0 To n Step 0.1
		'locate 1,1:print "l1 ";l1;" imaginary bar: yellow "
		'locate 2,1:print "l2 ";l2;" angl rot bar motor: green = ";n
		'locate 3,1:print "l3 ";l3;" link bar: red"
		'locate 4,1:print "l4 ";l4;" receptor mov: cyan"
		
		't_ink 8 : t_thick = 0.5 : t_distance_points = 10
		' rotation l2
		't_pos(0,0)  : t_circle l2
		' rotation l4
		't_pos(100,0): t_circle l4
		
		t_distance_points = 0
		t_pos(0,0)  :px1 = (Cos(t_radians(n)) * l2)    :py1 = Sin(t_radians(n)) * l2 'rotation l2
		t_pos(l1,0) :px2 = (Cos(t_radians(j)) * l4)+l1 :py2 = Sin(t_radians(j)) * l4 'rotation l4
		
		If j <= n And Int(t_long(px1,py1,px2,py2)) = l3 and k = 0 then
			ScreenLock
			Cls
			t_thick = 1
			t_ink 14: t_pos (0,0):   t_circle 3:t_lin_ang(0,0,l1,0):t_circle 3'l1, axes line, color  = yellow
			t_ink 10: t_pos (0,0):   t_lin_ang(0,0,px1,py1):t_circle 3    'l2, bar 2, color = green
			t_ink 12: t_pos(px1,py1):t_lin_ang(px1,py1,px2,py2):t_circle 3'l4, bar 3 link, color = red
			t_ink 11: t_pos(l1,0):   t_lin_ang(l1,0,px2,py2):t_circle 3   'l3, bar 4, color = cyan
			p1(j,1) = px1 : p1(j,2) = py1			
			p2(g,1) = px2 : p2(g,2) = py2
			For h = 1 To 1800
				Circle (p1(h,1),p1(h,2)),1,13,,,,f 'trajectory points l4
				Circle (p2(h,1),p2(h,2)),1,15,,,,f 'trajectory points l2				
			Next h
			g = g + 1
			k = 1
			ScreenUnlock
			Sleep 0.6
			GoTo paso
		EndIf
	Next j
	
	paso:
Next n
Color 12
Locate 22,1:Print "end"
Sleep
End
Regards
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Mechanics Waves

Post by lrcvs »

Hi,

This program is a simulation of mechanism of oscilation of bars

See:

https://www.youtube.com/watch?v=yEY_NYueJqI

Code: Select all

#include "turtle_9.bi"
'lrcvs, 06.08.16
'program mechanics waves

DIM AS double l, n, px1,px2,px3,px4,px5


CLS
l = 150 'long segment
px1 = -250
px2 = -100
px3 =   50
px4 =  200
px5 =  350
t_init

FOR n = 0 TO (360 * 5) STEP  0.5 'revolutions and speed

    SCREENLOCK
    CLS
    t_or 0: t_thick = 0.1 : t_ink 7:t_pos(-400,0): t_fd 800 'central axe horizontal
    
    t_ink 14: t_thick = 1
    t_pos(px1,0):t_circle 6 'axe 1
    t_pos(px2,0):t_circle 6 'axe 2
    t_pos(px3,0):t_circle 6 'axe 3
    t_pos(px4,0):t_circle 6 'axe 4
    t_pos(px5,0):t_circle 6 'axe 5
    
    t_pos(-350,0): t_ink 8: t_circle 50:t_ink 15: t_circle 2: t_ol n:t_fd 50: t_circle 3 'rotation main
    
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px1,0): t_fd l: t_ink 15:  t_circle 3 'segment_1
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px2,0): t_fd l: t_ink 15:  t_circle 3 'segment_2
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px3,0): t_fd l: t_ink 15:  t_circle 3 'segment_3
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px4,0): t_fd l: t_ink 15:  t_circle 3 'segment_4
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px5,0): t_fd l: t_ink 15:  t_circle 3 'segment_5
    SCREENUNLOCK
    SLEEP 0.6
NEXT n
SLEEP
END
Regards
Last edited by lrcvs on Aug 09, 2016 17:32, edited 5 times in total.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Mechanics Waves

Post by Tourist Trap »

lrcvs wrote:This program is a simulation of mechanism of oscilation of bars
Hi Ircvs!

Can you repost Turtle9.bi please? It is required to run your new demos ( and a little difficult to find it in the posts ;-) )
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Hi, Tourist Trap

Here Turtle_9.bi:

Code: Select all

'Turtle_9
'lrcvs 06.01.2016

DECLARE FUNCTION t_ang (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE,BYVAL t_y2 AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_apothem (BYVAL t_numsides AS INTEGER, BYVAL t_radius AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_degrees (BYVAL t_rad AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_long (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE, BYVAL t_y2 AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_lradius ( BYVAL t_long_side AS DOUBLE, BYVAL t_num_sides AS INTEGER) AS DOUBLE
DECLARE FUNCTION t_pol_rec_x (BYVAL t_radius AS DOUBLE, BYVAL t_angle AS INTEGER) AS DOUBLE
DECLARE FUNCTION t_pol_rec_y (BYVAL t_radius AS DOUBLE, BYVAL t_angle AS INTEGER) AS DOUBLE
DECLARE FUNCTION t_radians (BYVAL t_angle AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_rec_pol_angle (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_rec_pol_radius (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_side (BYVAL t_position_x AS DOUBLE, BYVAL t_position_y AS DOUBLE, BYVAL t_radius AS DOUBLE,  BYVAL t_numsides AS INTEGER) AS DOUBLE
DECLARE SUB t_arc_sec_star (BYVAL t_np AS INTEGER , BYVAL t_ang_ini AS DOUBLE , BYVAL t_ang_end AS DOUBLE ,BYVAL t_rg AS DOUBLE , BYVAL t_rp AS DOUBLE , BYVAL t_ang_rot AS DOUBLE, BYVAL t_arc_sec AS DOUBLE)
DECLARE SUB t_axes ()
DECLARE SUB t_bk (BYVAL t_distance AS DOUBLE)
DECLARE SUB t_circle (BYVAL t_r1 AS DOUBLE)
DECLARE SUB t_curves (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_ini AS DOUBLE , BYVAL t_ang_end AS DOUBLE , BYVAL t_ang_rot AS DOUBLE,BYVAL t_arc_sec AS DOUBLE)
DECLARE SUB t_ellipse (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
DECLARE SUB t_fd (BYVAL t_distance AS DOUBLE)
DECLARE SUB t_grid_1 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_grid_2 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_grid_3 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_grid_4 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_grid_5 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_gt (BYVAL t_position_x AS DOUBLE, BYVAL t_position_y AS DOUBLE)
DECLARE SUB t_home
DECLARE SUB t_init ()
DECLARE SUB t_ink (BYVAL t_col AS INTEGER)
DECLARE SUB t_lin_ang (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE,BYVAL t_y2 AS DOUBLE)
DECLARE SUB t_line_bk (BYVAL t_distance AS DOUBLE)
DECLARE SUB t_line_fd (BYVAL t_distance AS DOUBLE)
DECLARE SUB t_mem_pos ()
DECLARE SUB t_lt (BYVAL t_angle AS DOUBLE)
DECLARE SUB t_ol (BYVAL t_angle AS DOUBLE)
DECLARE SUB t_or (BYVAL t_angle AS DOUBLE)
DECLARE SUB t_ovoid (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_ang_rot AS DOUBLE)
DECLARE SUB t_pd ()
DECLARE SUB t_poly (BYVAL t_long_side AS DOUBLE, BYVAL t_num_sides AS INTEGER, BYVAL t_ang_rot AS DOUBLE)
DECLARE SUB t_pos (BYVAL t_position_x AS DOUBLE, BYVAL t_position_x AS DOUBLE)
DECLARE SUB t_pos_mem ()
DECLARE SUB t_pos_rot(BYVAL t_pos_rot_x AS DOUBLE, BYVAL t_pos_rot_y AS DOUBLE)
DECLARE SUB t_pu ()
DECLARE SUB t_rect(BYVAL t_side_upper AS DOUBLE, BYVAL t_side_lower AS DOUBLE, BYVAL t_ang_rot AS DOUBLE)
DECLARE SUB t_rhombus (BYVAL t_rg AS DOUBLE , BYVAL t_rp AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
DECLARE SUB t_rot_cir_l (BYVAL t_distance AS DOUBLE,BYVAL t_angle AS DOUBLE)
DECLARE SUB t_rot_cir_point (BYVAL t_ang_end AS DOUBLE)
DECLARE SUB t_rot_cir_r (BYVAL t_distance AS DOUBLE,BYVAL t_angle AS DOUBLE)
DECLARE SUB t_rot_ellipse_l (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_angle AS DOUBLE)
DECLARE SUB t_rot_ellipse_r (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_angle AS DOUBLE)
DECLARE SUB t_rt (BYVAL t_angle AS DOUBLE)
DECLARE SUB t_speed (BYVAL t_vel AS INTEGER)
DECLARE SUB t_spring (t_ns AS INTEGER , t_rs AS DOUBLE , t_lo AS DOUBLE) 'draw a t_spring
DECLARE SUB t_star (BYVAL t_np AS INTEGER , BYVAL t_rg AS DOUBLE , BYVAL t_rp AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
DECLARE SUB t_trace_ang (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_ini AS DOUBLE , BYVAL t_ang_end AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
DECLARE SUB t_vawes (BYVAL t_amp AS DOUBLE , BYVAL t_mod AS DOUBLE , BYVAL t_fre AS DOUBLE , BYVAL t_ini AS DOUBLE , BYVAL t_end AS DOUBLE , BYVAL t_rot AS DOUBLE )
DECLARE SUB t_rot_to_pos ()
DECLARE SUB t_photo ()

CONST            t_pi AS DOUBLE =  3.141592653589793238462643383279
CONST  t_number_aurum AS DOUBLE =  1.618033988749894848204586834365
CONST      t_number_e AS DOUBLE =  2.718281828459045235360287471352
CONST t_const_radians AS DOUBLE =  0.017453292519943295769236907684
CONST t_const_degrees AS DOUBLE = 57.295779513082320876798154814105

DIM SHARED AS INTEGER t_center_screen_x,t_center_screen_y,t_h,t_inverse_rotation, t_pause_arc_sec_star,t_pause_circle,t_pause_ellipse,t_pause_line,t_pause_poly,t_pause_rect,t_pause_rhombus,t_pause_spring,t_pause_trace_ang,t_turtle,t_w,t_pause,t_pause_curves,t_pause_ovoid,t_pause_star,t_pause_vawes
DIM SHARED AS DOUBLE t_angle,t_distance,t_distance_points,t_heading,t_heading_leftp, t_heading_leftn, t_heading_rigth, t_new_position_x,t_new_position_y,t_rot_point_x, t_rot_point_y, t_pos_rot_x, t_pos_rot_y,t_pos_x,t_pos_y,t_position_x,t_position_y,t_scale,t_thick
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

FUNCTION t_ang (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE, BYVAL t_y2 AS DOUBLE) AS DOUBLE
    DIM AS DOUBLE t_fang
    IF t_x1 < t_x2 AND t_y1 < t_y2 THEN t_fang = t_degrees(ACOS((t_x2 - t_x1)/SQR (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2))))
    IF t_x1 > t_x2 AND t_y1 < t_y2 THEN t_fang = t_degrees(ACOS((t_x2 - t_x1)/SQR (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2))))
    IF t_x1 > t_x2 AND t_y1 > t_y2 THEN t_fang = 360 - (t_degrees(ACOS((t_x2 - t_x1)/SQR (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2)))))
    IF t_x1 < t_x2 AND t_y1 > t_y2 THEN t_fang = 360 - (t_degrees(ACOS((t_x2 - t_x1)/SQR (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2)))))
    IF t_x1 < t_x2 AND t_y1 = t_y2 THEN t_fang = 0
    IF t_x1 = t_x2 AND t_y1 < t_y2 THEN t_fang = 90
    IF t_x1 > t_x2 AND t_y1 = t_y2 THEN t_fang = 180
    IF t_x1 = t_x2 AND t_y2 < t_y1 THEN t_fang = 270
    t_ang = t_fang
END FUNCTION

FUNCTION t_apothem (BYVAL t_numsides AS INTEGER, BYVAL t_radius AS DOUBLE) AS DOUBLE
    'calculate apothem
    t_apothem = (COS(t_radians((360/t_numsides)/2)) * t_radius)
END FUNCTION

FUNCTION t_degrees (BYVAL t_rad AS DOUBLE) AS DOUBLE
    'transform radians to degrees
    t_degrees = (t_rad * t_const_degrees)
END FUNCTION

FUNCTION t_long (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE, BYVAL t_y2 AS DOUBLE) AS DOUBLE
    'calculate long point to point
    t_long = SQR(ABS((t_x1 - t_x2)^2) + ABS((t_y1 - t_y2)^2))
END FUNCTION

FUNCTION t_lradius ( BYVAL t_long_side AS DOUBLE, BYVAL t_num_sides AS INTEGER) AS DOUBLE
    'calculate radius of one polygon
    t_lradius = (t_long_side * SIN(t_radians((180-(360/t_num_sides ))/2)))/SIN(t_radians(360/t_num_sides))
END FUNCTION

FUNCTION t_pol_rec_x (BYVAL t_radius AS DOUBLE, BYVAL t_angle AS INTEGER) AS DOUBLE
    'Transform coord polar X to coord rect X
    t_pol_rec_x = t_radius * COS (t_radians(t_angle))
END FUNCTION

FUNCTION t_pol_rec_Y (BYVAL t_radius AS DOUBLE, BYVAL t_angle AS INTEGER) AS DOUBLE
    'Transform coord polar y to coord rect Y
    t_pol_rec_Y = t_radius * SIN (t_radians(t_angle))
END FUNCTION

FUNCTION t_radians (BYVAL t_angle AS DOUBLE) AS DOUBLE
    'transfor degrees to radians
    t_radians  =  (t_angle * t_const_radians )
END FUNCTION

FUNCTION t_rec_pol_angle (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE) AS DOUBLE
    'Traslate  coord rect to polar, show the angle
    DIM AS INTEGER sx,sy
    sx = SGN(t_x1)
    sy = SGN(t_y1)
    IF sx =  1 AND sy =  1 THEN t_rec_pol_angle = t_degrees (ATN (t_y1/t_x1))
    IF sx = -1 AND sy =  1 THEN t_rec_pol_angle = 180 - ABS(t_degrees (ATN (t_y1/t_x1)))
    IF sx = -1 AND sy = -1 THEN t_rec_pol_angle = 180 + t_degrees (ATN (t_y1/t_x1))
    IF sx =  1 AND sy = -1 THEN t_rec_pol_angle = 360 - ABS(t_degrees (ATN (t_y1/t_x1)))
    IF sx =  1 AND sy =  0 THEN t_rec_pol_angle = 0
    IF sx =  0 AND sy =  1 THEN t_rec_pol_angle = 90
    IF sx = -1 AND sy =  0 THEN t_rec_pol_angle = 180
    IF sx =  0 AND sy = -1 THEN t_rec_pol_angle = 270
END FUNCTION

FUNCTION T_REC_POL_RADIUS (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE) AS DOUBLE
    T_REC_POL_RADIUS = SQR((T_X1^2)+(T_Y1^2))
END FUNCTION

FUNCTION t_side (BYVAL t_position_x AS DOUBLE, BYVAL t_position_y AS DOUBLE, BYVAL t_radius AS DOUBLE,  BYVAL t_num_sides AS INTEGER) AS DOUBLE
    'calculate a side od polygon
    DIM AS DOUBLE t_rgrad, t_x0, t_y0, t_x1, t_y1
    t_rgrad = t_radians(0)
    t_x0 = (t_radius * COS (t_rgrad)) + t_position_x
    t_y0 = (t_radius * SIN (t_rgrad)) + t_position_y
    t_rgrad = t_radians(360 / t_num_sides)
    t_x1 = (t_radius * COS (t_rgrad)) + t_position_x
    t_y1 = (t_radius * SIN (t_rgrad)) + t_position_y
    t_side= t_long (t_x0, t_y0, t_x1, t_y1)
END FUNCTION

SUB t_arc_sec_star (BYVAL t_np AS INTEGER , BYVAL t_ang_ini AS DOUBLE , BYVAL t_ang_end AS DOUBLE ,BYVAL t_rg AS DOUBLE , BYVAL t_rp AS DOUBLE , BYVAL t_ang_rot AS DOUBLE, BYVAL t_arc_sec AS DOUBLE)
    'draws an arc / sector of star
    't_np = number of points at 360 degrees
    't_ang_ini = angle init
    't_ang_end = angle end
    't_rg = larger radius
    't_rp = radius less
    't_ang_rot = rotation angle
    
    DIM AS DOUBLE t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2, t_c
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_c =0
    t_rg = t_rg * t_scale
    t_rp = t_rp * t_scale
    FOR  t_n = t_ang_ini  TO t_ang_end  STEP  (360/(t_np*2))
        IF  t_c MOD 2  = 0  THEN
            t_x1 = (t_rp  * COS(t_radians(t_n)))
            t_y1 = (t_rp  * SIN(t_radians(t_n)))
        ELSE
            t_x1  = (t_rg  * COS(t_radians(t_n)))
            t_y1 =  (t_rg  * SIN(t_radians(t_n)))
        END IF
        t_ol (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        IF t_c = 0 THEN t_pu ELSE t_pd
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
    NEXT t_n
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_arc_sec_star
END SUB


SUB t_axes ()
    LINE(-t_w/2  , t_center_screen_y) - ( t_w/2 , t_center_screen_y )
    LINE( t_center_screen_x ,-t_h/2 ) - ( t_center_screen_x , t_h/2 )
END SUB

SUB t_bk (BYVAL t_distance AS DOUBLE)
    t_line_bk t_distance
END SUB

SUB t_circle (BYVAL t_r1 AS DOUBLE)
    'draw a circle
    't_r = radius circle
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_curves (t_r1, t_r1,0,360,0,0)
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_circle
END SUB

SUB t_curves (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_ini AS DOUBLE , BYVAL t_ang_end AS DOUBLE , BYVAL t_ang_rot AS DOUBLE, BYVAL t_arc_sec AS DOUBLE)
    'draw circles, ellipses, arcs,....
    't_r1 = larger radius
    't_r2 = less radius
    't_ang_rot = rotation angle
    DIM AS DOUBLE t_grad , t_grad2,t_px,t_py,t_pz
    DIM AS DOUBLE t_px1,t_py1,t_pz1, t_dot_x, t_dot_y
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_r1 = t_r1 * t_scale
    t_r2 = t_r2 * t_scale
    t_ang_rot = t_radians (t_ang_rot)
    IF t_distance_points < 1 THEN t_distance_points = 1
    
    IF t_arc_sec = 1 THEN
        t_pos (t_px,t_py)
        t_grad2 = t_radians(t_ang_ini)
        t_dot_x = (((t_r1 * COS(t_grad2)) * COS (t_ang_rot)) - ((t_r2 * SIN(t_grad2)) * SIN (t_ang_rot))) + t_position_x
        t_dot_y = (((t_r1 * COS(t_grad2)) * SIN (t_ang_rot)) + ((t_r2 * SIN(t_grad2)) * COS (t_ang_rot))) + t_position_y
        t_ol t_ang(t_px, t_py, t_dot_x, t_dot_y )
        t_fd t_long(t_px, t_py, t_dot_x, t_dot_y )
    END IF
    
    FOR t_grad = t_ang_ini TO t_ang_end
        't_pos (t_px,t_py)
        t_grad2 = t_radians(t_grad)
        t_dot_x = (((t_r1 * COS(t_grad2)) * COS (t_ang_rot)) - ((t_r2 * SIN(t_grad2)) * SIN (t_ang_rot))) + t_position_x
        t_dot_y = (((t_r1 * COS(t_grad2)) * SIN (t_ang_rot)) + ((t_r2 * SIN(t_grad2)) * COS (t_ang_rot))) + t_position_y
        IF t_turtle = 1 AND t_grad MOD t_distance_points = 0  THEN CIRCLE (t_dot_x, t_dot_y), t_thick,,,,,f
    NEXT t_grad
    
    IF t_arc_sec = 1 THEN
        t_ol t_ang(t_px, t_py, t_dot_x, t_dot_y )
        t_fd t_long(t_px, t_py, t_dot_x, t_dot_y )
    END IF
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_curves
END SUB

SUB t_ellipse (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
    'draw a ellipse
    't_r1 = larger radius
    't_r2 = less radius
    't_ang_rot = rotation angle
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    't_px1 = t_position_x
    't_py1 = t_position_y
    't_pz1 = t_heading
    t_curves (t_r1,t_r2,0,360,t_ang_rot,0)
    't_position_x = t_px1
    't_position_y = t_py1
    't_heading = t_pz1
    SLEEP t_pause_ellipse
END SUB

SUB t_fd (BYVAL t_distance AS DOUBLE)
    't_line_fd t_distance
    t_line_fd t_distance
END SUB

SUB t_grid_1 (BYVAL t_step_grid AS DOUBLE)
    DIM t_n AS DOUBLE
    FOR t_n = -t_h TO t_h STEP t_step_grid
        LINE(-t_w , t_n) - (t_w , t_n),8  'horizontal lines
    NEXT t_n
END SUB

SUB t_grid_2 (BYVAL t_step_grid AS DOUBLE)
    DIM t_n AS DOUBLE
    FOR t_n = -t_w TO t_w STEP t_step_grid
        LINE(t_n , -t_h) - (t_n , t_h),8  'vertical lines
    NEXT t_n
END SUB

SUB t_grid_3 (BYVAL t_step_grid AS DOUBLE)
    DIM t_n AS DOUBLE
    FOR t_n = -t_h TO t_h STEP t_step_grid
        LINE(-t_w , t_n) - (t_w , t_n),8  'horizontal lines
    NEXT t_n
    FOR t_n = -t_w TO t_w STEP t_step_grid
        LINE(t_n , -t_h) - (t_n , t_h),8  'vertical lines
    NEXT t_n
END SUB

SUB t_grid_4(BYVAL t_step_grid AS DOUBLE)
    DIM t_n AS DOUBLE
    FOR t_n = 0 TO t_h STEP t_step_grid
        CIRCLE (0, 0), t_n ,8 'draw concentric circles
    NEXT t_n
END SUB

SUB t_grid_5 (BYVAL t_step_grid AS DOUBLE)
    DIM t_n AS DOUBLE
    COLOR 8
    FOR t_n = 0 TO 360 STEP t_step_grid
        'draw radius/angles
        t_ol t_n
        t_pos (0 ,0)
        t_fd t_w
    NEXT t_n
END SUB

SUB t_gt (BYVAL t_pos_x AS DOUBLE, BYVAL t_pos_y AS DOUBLE)
    IF t_turtle = 1 THEN
        t_ol t_ang (t_position_x, t_position_y, t_pos_x, t_pos_y)
        t_fd t_long (t_position_x, t_position_y, t_pos_x, t_pos_y)
    END IF
END SUB

SUB t_init ()
    SCREEN 19 '800*600
    SCREENINFO t_w , t_h
    WINDOW (-t_w/2,-t_h/2)-(t_w/2,t_h/2)
    COLOR 15
    t_center_screen_x = 0
    t_center_screen_y = 0
    t_inverse_rotation = 0
    t_position_x = t_center_screen_x
    t_position_y = t_center_screen_y
    t_distance_points = 1
    t_scale = 1
    t_speed 0
    t_turtle = 1
    t_thick = 0.1
END SUB

SUB t_ink (BYVAL t_col AS INTEGER)
    COLOR t_col
END SUB

SUB t_lin_ang (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE,BYVAL t_y2 AS DOUBLE)
t_ol t_ang(t_x1,t_y1,t_x2,t_y2)
t_fd t_long(t_x1,t_y1,t_x2,t_y2)
END SUB

SUB t_line_bk (BYVAL t_distance AS DOUBLE)
    DIM AS DOUBLE t_z, t_px, t_py, t_dot_x, t_dot_y, t_ang_ini,  t_ang_end 
    t_px = t_position_x
    t_py = t_position_y
    IF t_distance_points < 1 THEN t_distance_points = 1
    FOR t_z = 0 TO t_distance 
        if t_inverse_rotation = 0 then
        t_dot_x =t_px - (t_scale * COS(t_heading))
        t_dot_y =t_py + (t_scale * SIN(t_heading))
        else
        t_dot_x =t_px - (t_scale * COS(-t_heading))
        t_dot_y =t_py + (t_scale * SIN(-t_heading))
        end if
        IF t_turtle = 1 AND t_z MOD t_distance_points = 0 THEN CIRCLE (t_dot_x, t_dot_y), t_thick,,,,,f
        t_px =  t_dot_x
        t_py =  t_dot_y
        SLEEP t_pause_line
    NEXT t_z
    t_position_x = t_px
    t_position_y = t_py
END SUB

SUB t_line_fd (BYVAL t_distance AS DOUBLE)
    DIM AS DOUBLE t_z, t_px, t_py, t_dot_x, t_dot_y
    t_px = t_position_x
    t_py = t_position_y
    IF t_distance_points < 1 THEN t_distance_points = 1
    FOR t_z = 0 TO t_distance
        if t_inverse_rotation = 0 then
        t_dot_x =t_px + (t_scale * COS(t_heading))
        t_dot_y =t_py - (t_scale * SIN(t_heading))
        else
        t_dot_x =t_px - (t_scale * COS(-t_heading))
        t_dot_y =t_py + (t_scale * SIN(-t_heading))
        end if
        IF t_turtle = 1 AND t_z MOD t_distance_points = 0 THEN CIRCLE (t_dot_x, t_dot_y), t_thick,,,,,f
        t_px =  t_dot_x
        t_py =  t_dot_y
        SLEEP t_pause_line
    NEXT t_z
    t_position_x = t_px
    t_position_y = t_py
END SUB

SUB t_mem_pos ()
    DIM AS DOUBLE t_px1, t_py1, t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
END SUB

SUB t_lt (BYVAL t_angle AS DOUBLE)
    t_heading = t_heading - t_radians (t_angle)
END SUB

SUB t_ol (BYVAL t_angle AS DOUBLE)
    t_heading = t_radians (t_angle * (- 1))
END SUB

SUB t_or (BYVAL t_angle AS DOUBLE)
    t_heading = t_radians (t_angle)
END SUB

SUB t_ovoid (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_ang_rot AS DOUBLE)
    'draw ovoid
    't_r1 = larger radius
    't_r2 = less radius
    't_ang_rot = rotation angle
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_curves (t_r1,t_r2,0,180,t_ang_rot,0)
    t_curves (t_r1,t_r1,180,360,t_ang_rot,0)
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_ovoid
END SUB

SUB t_pd ()
	t_turtle = 1
END SUB

SUB t_photo ()
    'make a photo of screen
    DIM AS INTEGER t_nn, t_long_date_time
    DIM AS STRING t_date_time, t_name_photo, t_photo_y
    t_date_time = DATE
    t_long_date_time = LEN (t_date_time)
    t_name_photo = ""
    t_photo_y = ""
    FOR t_nn = 1 TO t_long_date_time
        t_photo_y= MID(t_date_time,t_nn,1)
        IF t_photo_y <> "-" THEN t_name_photo = t_name_photo + t_photo_y
    NEXT t_nn
    t_name_photo = t_name_photo + "_"
    t_date_time = TIME
    t_long_date_time = LEN (t_date_time)
    t_photo_y = ""
    FOR t_nn = 1 TO t_long_date_time
        t_photo_y= MID(t_date_time,t_nn,1)
        IF t_photo_y <> ":" THEN t_name_photo = t_name_photo + t_photo_y
    NEXT t_nn
    BSAVE t_name_photo+".bmp",0
END SUB

SUB t_poly (BYVAL t_long_side AS DOUBLE, BYVAL t_num_sides AS INTEGER, BYVAL t_ang_rot AS DOUBLE)
    'draws polygon
    't_long_side = side length
    't_num_sides = number of sides
    't_ang_rot = rotation angle
    DIM AS DOUBLE t_c, t_pol,t_x0,t_y0,t_x1,t_y1
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    IF t_num_sides < 3 THEN LOCATE 1,1:PRINT "error !!!":EXIT SUB
    t_pu
    FOR t_pol  = (359/t_num_sides) TO 360 + (360/t_num_sides) STEP (360/t_num_sides)
        t_x1 = t_lradius (t_long_side,t_num_sides)  * COS(t_radians(t_pol)) * t_scale
        t_y1 = t_lradius (t_long_side,t_num_sides)  * SIN(t_radians(t_pol)) * t_scale
        t_ol (t_ang (t_x0,t_y0,t_x1,t_y1) + t_ang_rot)
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_pd
    NEXT t_pol
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_poly
END SUB

SUB t_pos (BYVAL t_pos_x AS DOUBLE, BYVAL t_pos_y AS DOUBLE)
    t_position_x = t_pos_x
    t_position_y = t_pos_y
END SUB

SUB t_pos_mem ()
    DIM AS DOUBLE t_px1, t_py1, t_pz1
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
END SUB

SUB t_pos_rot (BYVAL t_pos_x AS DOUBLE, BYVAL t_pos_y AS DOUBLE)
    t_pos_rot_x = t_pos_x
    t_pos_rot_y = t_pos_y
END SUB


SUB t_pu ()
	t_turtle = 0
END SUB

SUB t_rect (BYVAL t_side_upper AS DOUBLE, BYVAL t_side_lower AS DOUBLE, BYVAL t_ang_rot AS DOUBLE)
    'draw a rectangle
    't_side_upper = larger side
    't_side_lower = less side
    't_ang_rot = rotation angle
    't_c = 1
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_ol t_ang_rot
    t_side_upper = t_side_upper * t_scale
    t_side_lower = t_side_lower * t_scale
    t_pu
    t_fd t_side_upper / 2
    t_pd
    t_lt 90
    t_fd t_side_lower / 2
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd (t_side_lower / 2)- t_thick
    t_lt 90
    t_pu
    t_fd t_side_upper / 2
    t_pd
    SLEEP t_pause_rect
    t_ol t_ang_rot
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
END SUB

SUB t_rhombus (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
    'draws a rhombus
    't_r2 = larger radius
    't_r1 = less radius
    't_ang_rot = rotation angle
    DIM AS DOUBLE t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2, t_c
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_r2 = t_r2 * t_scale
    t_r1 = t_r1 * t_scale
    t_c =0
    t_pu
    FOR  t_n = 0 TO 360 STEP 90
        t_n = t_n
        IF  t_c MOD 2  = 0  THEN
            t_x1 = (t_r1  * COS(t_radians(t_n)))
            t_y1 = (t_r1  * SIN(t_radians(t_n)))
        ELSE
            t_x1  = (t_r2  * COS(t_radians(t_n)))
            t_y1 =  (t_r2  * SIN(t_radians(t_n)))
        END IF
        t_ol (t_ang (t_x0,t_y0,t_x1,t_y1)+t_ang_rot)
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
        t_pd
    NEXT t_n
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_rhombus
END SUB

SUB t_rot_cir_l (BYVAL t_distance AS DOUBLE, BYVAL t_angle AS DOUBLE)
    t_position_x = ((t_distance * t_scale) * COS(t_radians (t_angle)))+t_position_x
    t_position_y = ((t_distance * t_scale) * SIN(t_radians (t_angle)))+t_position_y
    t_heading = t_radians (t_angle * (- 1))
END SUB

SUB t_rot_cir_point (BYVAL t_ang_end AS DOUBLE)
    'retorna las coordenadas finales de un punto una vez rotado
    'PRIMERO ACTIVAR LA SUB
    'al angulo inicial, le suma o resta el angulo final
    DIM AS DOUBLE t_ang_ini, t_r1
    t_ang_ini = t_ang (0,0,t_position_x, t_position_y)
    t_r1 = t_long (0,0,t_position_x, t_position_y) * t_scale
    t_ang_ini = t_radians (t_ang_ini)
    t_ang_end = t_radians (t_ang_end)
    t_rot_point_x = (((t_r1 * COS(t_ang_end)) * COS (t_ang_ini)) - ((t_r1 * SIN(t_ang_end)) * SIN (t_ang_ini)))
    t_rot_point_y = (((t_r1 * COS(t_ang_ini)) * SIN (t_ang_end)) + ((t_r1 * SIN(t_ang_ini)) * COS (t_ang_end)))
END SUB

SUB t_rot_cir_r (BYVAL t_distance AS DOUBLE, BYVAL t_angle AS DOUBLE)
    t_position_x = ((t_distance * t_scale) * COS(t_radians (t_angle)))+t_position_x
    t_position_y = ((t_distance * t_scale) * SIN(t_radians (t_angle)))+t_position_y
    t_heading = t_radians (t_angle)
END SUB

SUB t_rot_ellipse_l (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_angle AS DOUBLE)
    t_position_x = ((t_r1 * t_scale) * COS(t_radians (t_angle)))+ t_position_x
    t_position_y = ((t_r2 * t_scale) * SIN(t_radians (t_angle)))+ t_position_y
    t_heading = t_radians (t_angle * (- 1))
END SUB

SUB t_rot_ellipse_r (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_angle AS DOUBLE)
    t_position_x = ((t_r1 * t_scale) * COS(t_radians (t_angle*-1)))+ t_position_x
    t_position_y = ((t_r2 * t_scale) * SIN(t_radians (t_angle*-1)))+ t_position_y
    t_heading = t_radians (t_angle)
END SUB

SUB t_rt (BYVAL t_angle AS DOUBLE)
    t_heading = t_heading + t_radians (t_angle)
END SUB

SUB t_speed (BYVAL t_vel AS INTEGER)
    t_pause = t_vel
END SUB

SUB t_spring (t_ns AS INTEGER , t_rs AS DOUBLE , t_lo AS DOUBLE)
    'draw a t_spring
    't_ns = number of spirals
    't_rs = stretch of spiral 0...90
    't_lo = long of spiral
    DIM AS INTEGER t_n, t_c
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_c = 1
    t_lo = t_lo * t_scale
    FOR t_n = 1 TO t_ns
        t_rt t_rs
        t_fd t_lo
        t_lt t_rs * 2
        t_fd t_lo
        t_rt t_rs
    NEXT t_n
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_spring
END SUB

SUB t_star (BYVAL t_np AS INTEGER , BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
    'draw a star
    't_np = number of points
    't_r2 = larger radius
    't_r1 = radius less
    DIM AS DOUBLE t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2, t_c
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_c = 0
    t_pu
    FOR  t_n = 0  TO 360 STEP  360/(t_np*2)
        IF  t_c MOD 2  = 0  THEN
            t_x1 = (t_r1  * COS(t_radians(t_n)))
            t_y1 = (t_r1  * SIN(t_radians(t_n)))
        ELSE
            t_x1  = (t_r2  * COS(t_radians(t_n)))
            t_y1 =  (t_r2  * SIN(t_radians(t_n)))
        END IF
        t_ol (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
        t_pd
    NEXT t_n
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_star
END SUB

SUB t_trace_ang (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_ini AS DOUBLE , BYVAL t_ang_end AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    t_ol t_ang_ini + t_ang_rot 
    t_fd t_r1
    t_position_x = t_px1
    t_position_y = t_py1
    t_ol t_ang_end + t_ang_rot
    t_fd t_r2
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_trace_ang
END SUB

SUB t_vawes (BYVAL t_amp AS DOUBLE , BYVAL t_mod AS DOUBLE , BYVAL t_fre AS DOUBLE , BYVAL t_ini AS DOUBLE , BYVAL t_end AS DOUBLE , BYVAL t_rot AS DOUBLE )
    'draw vawes
    't_amp = amplitud
    't_mod = modulation
    't_fre = frecuency
    't_ini = angle ini
    't_end = angle end
    't_rot = angle rotation
    DIM AS DOUBLE t_a, t_g, t_o, t_x, t_y
    DIM AS DOUBLE t_px1,t_py1,t_pz1
    t_px1 = t_position_x
    t_py1 = t_position_y
    t_pz1 = t_heading
    IF t_mod = 0 THEN t_mod = 1
    FOR t_o = t_ini TO t_end * t_fre
        t_g = t_radians(t_o)
        t_a = t_radians(t_rot)
        t_position_x =  ((t_o * COS(t_a)/t_mod)-((t_amp  * t_scale * SIN(t_g))* SIN(t_a))) + t_pos_rot_x
        t_position_y =  ((t_o * SIN(t_a)/t_mod)+((t_amp  * t_scale * SIN(t_g))* COS(t_a))) + t_pos_rot_y
        t_fd 1
    NEXT t_o
    t_position_x = t_px1
    t_position_y = t_py1
    t_heading = t_pz1
    SLEEP t_pause_vawes
END SUB

Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Mechanics Waves

Post by Tourist Trap »

Thanks! (good mechanics stuff)
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Mechanics Waves, Part #2

Post by lrcvs »

Mechanics Waves, Part #2

Code: Select all

#include "turtle_9.bi"
'program mechanics waves


DIM AS double l, n, px1,px2,px3,px4,px5



CLS
'SLEEP 5000
l = 150 'long segment

px1 = -250
px2 = -100
px3 =   50
px4 =  200
px5 =  350
t_init
    
     
FOR n = 0 TO (405*1) STEP  0.5 'revolutions and speed
    SCREENLOCK
    CLS
     t_grid_3 20
   
    'if n = 0 then n = 0.1
    t_or 0: t_thick = 0.1 : t_ink 7:t_pos(-400,200): t_fd 800 'central axe horizontal
    
    t_ink 12: t_thick = 0.1
    t_pos(px1,200):t_circle 6 'axe 1
    t_pos(px2,200):t_circle 6 'axe 2
    t_pos(px3,200):t_circle 6 'axe 3
    t_pos(px4,200):t_circle 6 'axe 4
    t_pos(px5,200):t_circle 6 'axe 5
    
    t_pos(-350,200): t_ink 8: t_circle 50:t_ink 15: t_circle 2: t_ol n:t_fd 50: t_circle 3 'rotation main
    
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px1,200): t_fd l: t_ink 15:  t_circle 3 'segment_1
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px2,200): t_fd l: t_ink 15:  t_circle 3 'segment_2
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px3,200): t_fd l: t_ink 15:  t_circle 3 'segment_3
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px4,200): t_fd l: t_ink 15:  t_circle 3 'segment_4
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px5,200): t_fd l: t_ink 15:  t_circle 3 'segment_5
 
    SCREENUNLOCK
    SLEEP 0.6
    
NEXT n
     
FOR n = 0 TO (360 * 1) STEP  10 'revolutions and speed
    SCREENLOCK
    'CLS
     't_grid_3 20
   
    'if n = 0 then n = 0.1
    t_or 0: t_thick = 0.1 : t_ink 7:t_pos(-400,0): t_fd 800 'central axe horizontal
    
    t_ink 12: t_thick = 0.1
    t_pos(px1,0):t_circle 6 'axe 1
    t_pos(px2,0):t_circle 6 'axe 2
    t_pos(px3,0):t_circle 6 'axe 3
    t_pos(px4,0):t_circle 6 'axe 4
    t_pos(px5,0):t_circle 6 'axe 5
    
    t_pos(-350,0): t_ink 8: t_circle 50:t_ink 15: t_circle 2: t_ol n:t_fd 50: t_circle 3 'rotation main
    
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px1,0): t_fd l: t_ink 15:  't_circle 3 'segment_1
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px2,0): t_fd l: t_ink 15:  't_circle 3 'segment_2
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px3,0): t_fd l: t_ink 15:  't_circle 3 'segment_3
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px4,0): t_fd l: t_ink 15:  't_circle 3 'segment_4
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px5,0): t_fd l: t_ink 15:  't_circle 3 'segment_5
 
    SCREENUNLOCK
    SLEEP 0.6
    
NEXT n

FOR n = 0 TO (360 * 1) STEP  0.5 'revolutions and speed
    SCREENLOCK
    'CLS
    't_grid_3 20
    'if n = 0 then n = 0.1
    't_or 0: t_thick = 0.1 : t_ink 7:t_pos(-400,-200): t_fd 800 'central axe horizontal
    
    t_ink 12: t_thick = 0.1
    t_pos(px1,-200):t_circle 6 'axe 1
    t_pos(px2,-200):t_circle 6 'axe 2
    t_pos(px3,-200):t_circle 6 'axe 3
    t_pos(px4,-200):t_circle 6 'axe 4
    t_pos(px5,-200):t_circle 6 'axe 5
    
    t_pos(-350,-200): t_ink 8: t_circle 50:t_ink 15: t_circle 2: t_ol n:t_fd 50: t_circle 3 'rotation main
    
 
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px1,-200): T_PU : t_fd l: t_ink 15: T_PD:  t_circle 0.1 'segment_1
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px2,-200): T_PU : t_fd l: t_ink 15: T_PD:  t_circle 0.1 'segment_2
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px3,-200): T_PU : t_fd l: t_ink 15: T_PD:  t_circle 0.1 'segment_3
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px4,-200): T_PU : t_fd l: t_ink 15: T_PD:  t_circle 0.1 'segment_4
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px5,-200): T_PU : t_fd l: t_ink 15: T_PD:  t_circle 0.1 'segment_5
   
    SCREENUNLOCK
    SLEEP 0.6
    
NEXT n

SLEEP
END

lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Mechanics Waves, Part #3

Post by lrcvs »

Hi:

Mechanics Waves, Part #3

https://www.youtube.com/watch?v=ZPZraZ4G80M

Code: Select all

#include "turtle_9.bi"
'program mechanics waves


DIM AS double l, n, px1,px2,px3,px4,px5,px6,px7,px8,py1,py2,py3,py4,py5,py6,py7,py8



CLS
l = 150 'long segment

px1 = -150
px2 = -150
px3 =  -100
px4 =  -100

px5 =  -100
px6 =  -100
px7 =  -50
px8 =  -50

py1 = 0
py2 = 50
py3 = 50
py4 = 0

py5 = -50
py6 = -100
py7 = -100
py8 = -150

t_init
T_SCALE = 1
FOR n = 0 TO (360 * 20) STEP  1 'revolutions and speed
    SCREENLOCK
    CLS
    
    if n = 0 then n = 0.1
    t_or 0
    line (-800,-600)-(800,600),1,bf
    t_thick = 3
    t_ink 7:t_pos(px1,py1):t_circle 6 'axe 1 
    t_ink 8:t_pos(px2,py2):t_circle 6 'axe 2 
    t_ink 9:t_pos(px3,py3):t_circle 6 'axe 3 
    t_ink 10:t_pos(px4,py4):t_circle 6 'axe 4 
    t_ink 11:t_pos(px5,py5):t_circle 6 'axe 5
    t_ink 12:t_pos(px6,py6):t_circle 6 'axe 6 
    t_ink 13:t_pos(px7,py7):t_circle 6 'axe 7 
    t_ink 14:t_pos(px8,py8):t_circle 6 'axe 8 
    
    t_pos(-250,0): t_ink 5: t_circle 50:t_ink 6: t_circle 2: t_ol n:t_fd 50: t_circle 3 'rotation main
    
    t_ink 7:t_ol t_ang(t_position_x, t_position_y,px1,py1): t_fd l: t_ink 15:  t_circle 3 'segment_1
    t_ink 8:t_ol t_ang(t_position_x, t_position_y,px2,py2): t_fd l: t_ink 15:  t_circle 3 'segment_2
    t_ink 9:t_ol t_ang(t_position_x, t_position_y,px3,py3): t_fd l: t_ink 15:  t_circle 3 'segment_3
    t_ink 10:t_ol t_ang(t_position_x, t_position_y,px4,py4): t_fd l: t_ink 15:  t_circle 3 'segment_4
    t_ink 11:t_ol t_ang(t_position_x, t_position_y,px5,py5): t_fd l: t_ink 15:  t_circle 3 'segment_5
    t_ink 12:t_ol t_ang(t_position_x, t_position_y,px6,py6): t_fd l: t_ink 15:  t_circle 3 'segment_6
    t_ink 13:t_ol t_ang(t_position_x, t_position_y,px7,py7): t_fd l: t_ink 15:  t_circle 3 'segment_7
    t_ink 14:t_ol t_ang(t_position_x, t_position_y,px8,py8): t_fd l: t_ink 15:  t_circle 3 'segment_8
    
    SCREENUNLOCK
    SLEEP 0.6
NEXT n
SLEEP
END

lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Simulator Pegasus Bridge, Normandie (France)

Post by lrcvs »

Hi:

Simulator Pegasus Bridge

See:
https://www.youtube.com/watch?v=h8MWFZTzTHI
Please: >>> Turtle_9.bi >>> here >>> : http://www.freebasic.net/forum/viewtopi ... 90#p222976

Code: Select all

#include "turtle_9.bi"
'Programa: Simulator Pegasus Bridge, Normandia (France)
'21.08.2016

DIM  AS DOUBLE n, a
CLS
t_init

'elevacion del puente
FOR a = 0 TO 80
    SCREENLOCK
    CLS
    t_ink 15 : t_thick = 1 : t_pos(342,-187):t_rect (100,30,0)'extremo final del puente
    t_ink 11 : t_pos(80,-280):t_rect (420,150,0):t_ink 15 'agua
    'movimiento inicial de separacion
    IF a < 21 THEN
        t_pos(-130-a,-70)
        t_ol 90
        t_fd 110
        t_ol 225
        t_fd 154
        t_bk 154
        t_ol 316
        t_fd 305
        t_bk 153
        t_ol 225
        t_fd 153
        t_pos(-130-a,40)
        t_ol 180
        t_fd 108
        t_ol 270
        t_fd 110
        t_ol 0
        t_fd 60
        t_ol 90
        t_fd 110
        t_pos(-130-a,-70) 'centro eje rotacion
        t_curves (90,90,180,270,0,0)
        t_curves (110,110,180,270,0,0)
        t_ol 270
        t_fd 110
        t_pos(-130-a,-70) 'centro eje rotacion
        t_ol 180
        t_fd 100
        t_pos(-130-a,-70) 'centro eje rotacion
        'plataforma
        t_ol 270
        t_pu
        t_fd 110
        t_pd
        t_fd 20
        t_ol 0
        t_fd 420
        t_ol 90
        t_fd 30
        t_ol 180
        t_fd 420
        FOR n = 0 TO 360 STEP 30
            t_bk 30
            t_ol 270
            t_fd 30
            t_bk 30
            t_ol 180
        NEXT n
        t_fd 400
        t_ol 90
        t_fd 10
        t_ol 340
        t_fd 30
        t_pos(-130-a,-70) : t_circle 5
        'radios
        FOR n = 180 TO 270 STEP 10
            t_pos(-130-a,-70)
            t_ol n
            t_pu
            t_fd 90
            t_pd
            t_fd 18
        NEXT n
        t_pos(-135-a,-185) : t_circle 5
    END IF
    ' movimiento de separacion de retroceso y rotacion
    IF a >= 21 THEN
        t_pos(-130-a,-70)
        t_ol 90 +(a-21)
        t_fd 110
        t_ol 225 +(a-21)
        t_fd 154
        t_bk 154
        t_ol 316 +(a-21)
        t_fd 305
        t_bk 153
        t_ol 225 +(a-21)
        t_fd 153
        t_bk 153
        t_ol 136 +(a-21)
        t_fd 150
        t_ol 180 +(a-21)
        t_fd 108
        t_ol 270 +(a-21)
        t_fd 110
        t_ol 0 +(a-21)
        t_fd 60
        t_ol 90 +(a-21)
        t_fd 110
        t_pos(-130-a,-70)
        t_curves (90,90,180,270,(a-21),0)
        t_curves (110,110,180,270,a-21,0)
        t_pos(-130-a,-70) 'centro eje rotacion
        t_ol 180+(a-21)
        t_fd 100
        t_pos(-130-a,-70) 'centro eje rotacion
        t_ol 270+(a-21)
        t_fd 110
        t_pos(-130-a,-70) 'centro eje rotacion
        'plataforma
        t_ol 270 +(a-21)
        t_pu
        t_fd 110
        t_pd
        t_fd 20
        t_ol 0  +(a-21)
        t_fd 420
        t_ol 90  +(a-21)
        t_fd 30
        t_ol 180  +(a-21)
        t_fd 420
        FOR n = 0 TO 360 STEP 30
            t_bk 30
            t_ol 270  +(a-21)
            t_fd 30
            t_bk 30
            t_ol 180  +(a-21)
        NEXT n
        t_fd 400
        t_ol 90 +(a-21)
        t_fd 10
        t_ol 340 +(a-21)
        t_fd 30
        t_pos(-130-a,-70) : t_circle 5
        'radios
        FOR n = 180 TO 270 STEP 10
            t_pos(-130-a,-70)
            t_ol n+a-21
            t_pu
            t_fd 90
            t_pd
            t_fd 18
        NEXT n
        t_pos(-135-a,-185) : t_circle 5
    END IF
    'estructura / soporte fija

    t_thick =  3
    t_ink 2
    t_pos(-150,-33):t_rect (40,70,0)' SALA DE MAQUINAS
    'SOPORTE
    t_pos(-240,-130):t_rect (220,120,0)
    t_pos(-250,-70):t_ol 315:t_fd 168
    t_pos(-250,-70):t_ol 230:t_fd 155
    t_thick = 1
    SCREENUNLOCK
    SLEEP 150
NEXT a

':::::::::::::::::::::::::::::::::::
sleep 2000
'descenso del puente
FOR a = 80 TO 0 step -1
    SCREENLOCK
    CLS
    t_ink 15 : t_thick = 1 : t_pos(342,-187):t_rect (100,30,0)'extremo final del puente
    t_ink 11 : t_pos(80,-280):t_rect (420,150,0):t_ink 15 'agua
    'movimiento inicial de separacion
    IF a < 21 THEN
        t_pos(-130-a,-70)
        t_ol 90
        t_fd 110
        t_ol 225
        t_fd 154
        t_bk 154
        t_ol 316
        t_fd 305
        t_bk 153
        t_ol 225
        t_fd 153
        t_pos(-130-a,40)
        t_ol 180
        t_fd 108
        t_ol 270
        t_fd 110
        t_ol 0
        t_fd 60
        t_ol 90
        t_fd 110
        t_pos(-130-a,-70) 'centro eje rotacion
        t_curves (90,90,180,270,0,0)
        t_curves (110,110,180,270,0,0)
        t_ol 270
        t_fd 110
        t_pos(-130-a,-70) 'centro eje rotacion
        t_ol 180
        t_fd 100
        t_pos(-130-a,-70) 'centro eje rotacion
        'plataforma
        t_ol 270
        t_pu
        t_fd 110
        t_pd
        t_fd 20
        t_ol 0
        t_fd 420
        t_ol 90
        t_fd 30
        t_ol 180
        t_fd 420
        FOR n = 0 TO 360 STEP 30
            t_bk 30
            t_ol 270
            t_fd 30
            t_bk 30
            t_ol 180
        NEXT n
        t_fd 400
        t_ol 90
        t_fd 10
        t_ol 340
        t_fd 30
        t_pos(-130-a,-70) : t_circle 5
        'radios
        FOR n = 180 TO 270 STEP 10
            t_pos(-130-a,-70)
            t_ol n
            t_pu
            t_fd 90
            t_pd
            t_fd 18
        NEXT n
        t_pos(-135-a,-185) : t_circle 5
    END IF
    ' movimiento de separacion de retroceso y rotacion
    IF a >= 21 THEN
        t_pos(-130-a,-70)
        t_ol 90 +(a-21)
        t_fd 110
        t_ol 225 +(a-21)
        t_fd 154
        t_bk 154
        t_ol 316 +(a-21)
        t_fd 305
        t_bk 153
        t_ol 225 +(a-21)
        t_fd 153
        t_bk 153
        t_ol 136 +(a-21)
        t_fd 150
        t_ol 180 +(a-21)
        t_fd 108
        t_ol 270 +(a-21)
        t_fd 110
        t_ol 0 +(a-21)
        t_fd 60
        t_ol 90 +(a-21)
        t_fd 110
        t_pos(-130-a,-70)
        t_curves (90,90,180,270,(a-21),0)
        t_curves (110,110,180,270,a-21,0)
        t_pos(-130-a,-70) 'centro eje rotacion
        t_ol 180+(a-21)
        t_fd 100
        t_pos(-130-a,-70) 'centro eje rotacion
        t_ol 270+(a-21)
        t_fd 110
        t_pos(-130-a,-70) 'centro eje rotacion
        'plataforma
        t_ol 270 +(a-21)
        t_pu
        t_fd 110
        t_pd
        t_fd 20
        t_ol 0  +(a-21)
        t_fd 420
        t_ol 90  +(a-21)
        t_fd 30
        t_ol 180  +(a-21)
        t_fd 420
        FOR n = 0 TO 360 STEP 30
            t_bk 30
            t_ol 270  +(a-21)
            t_fd 30
            t_bk 30
            t_ol 180  +(a-21)
        NEXT n
        t_fd 400
        t_ol 90 +(a-21)
        t_fd 10
        t_ol 340 +(a-21)
        t_fd 30
        t_pos(-130-a,-70) : t_circle 5
        'radios
        FOR n = 180 TO 270 STEP 10
            t_pos(-130-a,-70)
            t_ol n+a-21
            t_pu
            t_fd 90
            t_pd
            t_fd 18
        NEXT n
        t_pos(-135-a,-185) : t_circle 5
    END IF
    'estructura / soporte fija

    t_thick =  3
    t_ink 2
    t_pos(-150,-33):t_rect (40,70,0)' SALA DE MAQUINAS
    'SOPORTE
    t_pos(-240,-130):t_rect (220,120,0)
    t_pos(-250,-70):t_ol 315:t_fd 168
    t_pos(-250,-70):t_ol 230:t_fd 155
    t_thick = 1
    SCREENUNLOCK
    SLEEP 150
NEXT a

SLEEP
END
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Simulator Pegasus Bridge, Normandie (France)

Post by Tourist Trap »

lrcvs wrote:Hi:

Simulator Pegasus Bridge
This bridge is really well done Ircvs. Exactly like the real one:
Image
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Hi, Tourist Trap:

Thanks!
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Hexapod Robot

Post by lrcvs »

HI:

This is my Hexapod Robot Wheels Telescopics

See:

https://www.youtube.com/watch?v=wen4n_q89yU

Code: Select all

#include "turtle_9.bi"
'Programa robot hexapodo con "ruedas" telescopicas

DECLARE SUB t_telescopic_cilinder (t_diam_cil AS DOUBLE, t_long_total AS DOUBLE, t_steps AS DOUBLE, t_position_step AS DOUBLE, t_rot_cil AS DOUBLE, t_radius_rot AS DOUBLE)
DIM AS integer p,r,v,x,y,z
CLS
t_init
r = 0 '<<<<< 0 = off  1 = on  show " wheels telescopics " side left, modify this !!!! <<<<<<<<<<<<<<<<
z = 60 'longitud total del cilindro telescopico
p = 120 'angulo entre cilindros

FOR x = -700 TO 500 STEP 2'posicion x
    SCREENLOCK
    CLS
        line (150,0)-(155,30),15,bf 'obstaculo
    FOR y = 0 TO 360 STEP p 'angulo de rotacion
        t_ink 11:t_thick = 1: t_pos (x+150,v+20):t_rect (300,20,0):t_thick = 0.1'cuerpo
        
        'soportes ruedas
        t_ink 14: t_pos (x,v)    : t_poly (30,3,y-x)
        t_ink 14: t_pos (x+150,v): t_poly (30,3,(y-x)+180)
        t_ink 14: t_pos (x+300,v): t_poly (30,3,y-x)
        'ruedas lado derecho
        t_ink 10: t_pos (x,v)    :t_telescopic_cilinder (10,z,3,v,y-x,0)
        t_ink 10: t_pos (x+150,v):t_telescopic_cilinder (10,z,3,v,(y-x)+(p/2),0)
        t_ink 10: t_pos (x+300,v):t_telescopic_cilinder (10,z,3,v,(y-x)+(2*p),0)
        
        'ruedas lado izquierdo
        IF r = 1 THEN 
        t_ink 11:t_thick = 1: t_pos (x+150,v+20):t_rect (300,20,0):t_thick = 0.1 'cuerpo
        'soportes ruedas lado izquierdo
        t_ink 14: t_pos (x,v)    : t_poly (30,3,y-x+180)
        t_ink 14: t_pos (x+150,v): t_poly (30,3,(y-x))
        t_ink 14: t_pos (x+300,v): t_poly (30,3,y-x+180)
        'ruedas lado izquierdo
        t_ink 12: t_pos (x,v)    :t_telescopic_cilinder (10,z,3,v,(y-x)+(p/2),0)
        t_ink 12: t_pos (x+150,v):t_telescopic_cilinder (10,z,3,v,(y-x)+(p),0)
        t_ink 12: t_pos (x+300,v):t_telescopic_cilinder (10,z,3,v,(y-x)+(p/2),0)
        end if
       
   	 'elevacion ruedas
   	 IF x >= -200 AND x < 0 THEN
   	 v = v + 1
   	 IF v >= z THEN v = z
   	 END IF

  	  'descenso ruedas
    	IF x > 130 THEN
   	 v = v - 1
  	 IF v < 0 THEN v = 0
   	 END IF
   	 
	NEXT y
    SCREENUNLOCK
    SLEEP 0.6
NEXT x

LOCATE 1,1:PRINT "end"
SLEEP
END




'init telescopic cilinder
SUB t_telescopic_cilinder (t_diam_cil AS DOUBLE, t_long_total AS DOUBLE, t_steps AS DOUBLE, t_position_step AS DOUBLE, t_rot_cil AS DOUBLE, t_radius_rot AS DOUBLE)
    DIM t_tot_steps AS INTEGER
    DIM AS DOUBLE t_long_step , t_ring , t_ntc
    't_diam_cil = diameter of cilinder
    't_long_total = long total
    't_steps = number od steps
    't_position = position extreme cilinder
    't_rot_cil = angle of rotation of cilinder
    't_radius_rot = point radius rotation
    t_tot_steps = t_steps + 1
    t_ring = (t_diam_cil/2) / (t_steps)
    t_long_step = t_long_total / t_steps
    IF t_position_step > t_long_step THEN t_position_step = t_long_step : END IF
    IF t_radius_rot > t_long_step THEN t_radius_rot = t_long_step : END IF
    t_ol t_rot_cil
    'init part radius rotation
    t_circle 5
    t_pu
    t_fd t_radius_rot  * (-1)
    t_pd
    'init_part
    t_rt 90
    t_fd (t_ring * t_steps)
    t_lt 90
    t_fd t_long_step
    t_lt 90
    t_fd (t_ring * t_steps)*2
    t_lt 90
    t_fd t_long_step
    t_lt 90
    t_fd (t_ring * t_steps)
    t_pu
    t_lt 90
    t_fd t_long_step
    t_pd
    'steps parts
    FOR t_ntc = 1 TO t_steps - 1
        t_rt 90
        t_fd (t_ring * ((t_steps - t_ntc) ))
        t_lt 90
        t_fd t_position_step
        t_lt 90
        t_fd (t_ring * ((t_steps - t_ntc) ))*2
        t_lt 90
        t_fd t_position_step
        t_lt 90
        t_fd (t_ring * ((t_steps - t_ntc)))
        t_pu
        t_lt 90
        t_fd t_position_step
        t_pd
    NEXT t_ntc
END SUB
'end telescopic cilinder

Regards
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Hi, this is the Ver #2

Code: Select all

#include "turtle_9.bi"
'Programa robot hexapodo con "ruedas" telescopicas
'Ver #2

DECLARE SUB t_telescopic_cilinder (t_diam_cil AS DOUBLE, t_long_total AS DOUBLE, t_steps AS DOUBLE, t_position_step AS DOUBLE, t_rot_cil AS DOUBLE, t_radius_rot AS DOUBLE)
DIM AS integer p,r,s,v,w,x,y,z
CLS
t_init
r = 0 '<<<<< 0 = off  1 = on  show " wheels telescopics " side left, modify this !!!! <<<<<<<<<<<<<<<<
z = 60 'longitud total del cilindro telescopico
p = 120 'angulo entre cilindros
s = 3 'secciones del cilindro telescopico
FOR x = -700 TO 500 STEP 2'posicion x
    SCREENLOCK
    CLS
    t_ink 6 : t_thick = 2:t_pos_rot(-600,-25) : t_waves (3,2,8,0,360,0) 'suelo
        line (130,-25)-(135,30),15,bf 'obstaculo
    FOR y = 0 TO 360 STEP p 'angulo de rotacion
        
        'efecto radar
        for w = 0 to 50 step 10
            t_distance_points = 5
            t_ink 14
            t_thick = 0.1
            if x mod 5 = 0 then 
                t_pos (x+300,v):t_curves (w,w,0, 180,270,0)
                t_pos (x,v):t_curves (w,w,0, 180,90,0)
            end if                    
        next w
        
        t_distance_points = 0
        t_ink 11:t_thick = 1: t_pos (x+150,v+20):t_rect (300,20,0):t_thick = 0.1'cuerpo
        
        'soportes ruedas
        t_ink 14: t_pos (x,v)    : t_poly (30,3,y-x)
        t_ink 14: t_pos (x+150,v): t_poly (30,3,(y-x)+180)
        t_ink 14: t_pos (x+300,v): t_poly (30,3,y-x)
        'ruedas lado derecho
        t_ink 10: t_pos (x,v)    :t_telescopic_cilinder (10,z,s,v,y-x,0)
        t_ink 10: t_pos (x+150,v):t_telescopic_cilinder (10,z,s,v,(y-x)+(p/2),0)
        t_ink 10: t_pos (x+300,v):t_telescopic_cilinder (10,z,s,v,(y-x)+(2*p),0)
        
        'ruedas lado izquierdo
        IF r = 1 THEN 
        t_ink 11:t_thick = 1: t_pos (x+150,v+20):t_rect (300,20,0):t_thick = 0.1 'cuerpo
        'soportes ruedas lado izquierdo
        t_ink 14: t_pos (x,v)    : t_poly (30,3,y-x+180)
        t_ink 14: t_pos (x+150,v): t_poly (30,3,(y-x))
        t_ink 14: t_pos (x+300,v): t_poly (30,3,y-x+180)
        'ruedas lado izquierdo
        t_ink 12: t_pos (x,v)    :t_telescopic_cilinder (10,z,s,v,(y-x)+(p/2),0)
        t_ink 12: t_pos (x+150,v):t_telescopic_cilinder (10,z,s,v,(y-x)+(p),0)
        t_ink 12: t_pos (x+300,v):t_telescopic_cilinder (10,z,s,v,(y-x)+(p/2),0)
        end if
    
    'elevacion ruedas
    IF x >= -200 AND x < 0 THEN
    v = v + 1
    IF v >= z THEN v = z
    END IF

    'descenso ruedas
    IF x > 130 THEN
    v = v - 1
    IF v < 0 THEN v = 0
    END IF
NEXT y

    SCREENUNLOCK
    SLEEP 0.6
NEXT x

LOCATE 1,1:PRINT "end"
SLEEP
END




'init telescopic cilinder
SUB t_telescopic_cilinder (t_diam_cil AS DOUBLE, t_long_total AS DOUBLE, t_steps AS DOUBLE, t_position_step AS DOUBLE, t_rot_cil AS DOUBLE, t_radius_rot AS DOUBLE)
    DIM t_tot_steps AS INTEGER
    DIM AS DOUBLE t_long_step , t_ring , t_ntc
    't_diam_cil = diameter of cilinder
    't_long_total = long total
    't_steps = number od steps
    't_position = position extreme cilinder
    't_rot_cil = angle of rotation of cilinder
    't_radius_rot = point radius rotation
    t_tot_steps = t_steps + 1
    t_ring = (t_diam_cil/2) / (t_steps)
    t_long_step = t_long_total / t_steps
    IF t_position_step > t_long_step THEN t_position_step = t_long_step : END IF
    IF t_radius_rot > t_long_step THEN t_radius_rot = t_long_step : END IF
    t_ol t_rot_cil
    'init part radius rotation
    t_circle 5
    t_pu
    t_fd t_radius_rot  * (-1)
    t_pd
    'init_part
    t_rt 90
    t_fd (t_ring * t_steps)
    t_lt 90
    t_fd t_long_step
    t_lt 90
    t_fd (t_ring * t_steps)*2
    t_lt 90
    t_fd t_long_step
    t_lt 90
    t_fd (t_ring * t_steps)
    t_pu
    t_lt 90
    t_fd t_long_step
    t_pd
    'steps parts
    FOR t_ntc = 1 TO t_steps - 1
        t_rt 90
        t_fd (t_ring * ((t_steps - t_ntc) ))
        t_lt 90
        t_fd t_position_step
        t_lt 90
        t_fd (t_ring * ((t_steps - t_ntc) ))*2
        t_lt 90
        t_fd t_position_step
        t_lt 90
        t_fd (t_ring * ((t_steps - t_ntc)))
        t_pu
        t_lt 90
        t_fd t_position_step
        t_pd
    NEXT t_ntc
END SUB
'end telescopic cilinder
Post Reply