[j2code]
NEW
LOAD
SAVE
*
LINK
PUBLISH
EXAMPLES
HELP
ABOUT
level 1
2
3
turtle
ARC length angle
CIRCLE radius
CLEARTEXT
HIDETURTLE
PENWIDTH width
PRINT [ . ]
RESET
SETHEADING angle
SETX x
SETXY x y
SETY y
SHOWTURTLE
maths
ARCTAN number
COS angle
INT number
RANDOM number
ROUND number
SIN angle
SQRT number
lists
BUTFIRST list
BUTLAST list
FIRST list
FPUT thing list
ITEM index thing
LAST list
LPUT thing list
SETITEM index array value
Level 3 - use buttons or type in the script area. Click play to run the script.
MAKE "sides 10 ; number of sides MAKE "webstartgap 10 ; start dist from center for each outward line MAKE "angle 360 / :sides MAKE "weblength 500 clear cleartext TO drawincircle :len :bx :by :cx :cy :headoff ;find the length of the 3rd side of triangle ;asq = bsq + csq − 2bc cosA ;print [:len :bx :by :cx :cy :headoff] MAKE "aa :angle ;aa is angle opp side a MAKE "b :len ;b is one side of triangle MAKE "c :len ;c is another side of triangle MAKE "i :b * :b + :c * :c ;is bsq + csq of formula above MAKE "j 2 * :b * :c * cos:aa ;is 2bc cosA of formula above MAKE "asq :i - :j ;is asq MAKE "a sqrt :asq ;third unknown side length MAKE "perimeter :a + :b + :c MAKE "halfp :perimeter / 2 ;find center point of circle that can be drawn in the triangle ;Ox = (a*Ax + b*Bx + cCx) / perimeter ;Oy = (a*Ay + b*By + cCy) / perimeter MAKE "ax 0 ;always at the center MAKE "ay 0 ;always at the center MAKE "ox :a*:ax + :b*:bx + :c*:cx MAKE "ox :ox / :perimeter MAKE "oy :a*:ay + :b*:by + :c*:cy MAKE "oy :oy / :perimeter ;print [:ox :oy] ;draw c line that encloses the circle ;pu setxy :cx :cy ;pd setxy :bx :by pu ;find the area of the triangle ;sqrt (p ( p − a ) ( p − b ) ( p − c )) MAKE "pa :halfp - :a MAKE "pb :halfp - :b MAKE "pc :halfp - :c MAKE "area sqrt :halfp * :pa * :pb * :pc ;print [:pa :pb :pc :area] MAKE "inradius 2 * :area / :perimeter ;print [:inradius] ;calc touch points of incircle ;if a1+a2=a and b1+b2=b and c1+c2=c ;then ;a1+b1+c1=halfp ;and b1 = halfp - a MAKE "b1 :halfp - :a ;angle at center of oa MAKE "oa 180 - 90 - :aa/2 ;angle along a to o perpendicular line through touch point bc MAKE "oa2 180 - :oa MAKE "touchheading :aa/2 + :oa2 + :headoff ;print [:touchheading] setxy :ox :oy setheading :touchheading pd arc :inradius 180-:aa ;arc :inradius 359 ;draw full circle for debugging END TO drawjoins :start :length :angle pu setheading :angle setxy 0 0 fd :start pd fd :length END FOR [i 0 :sides ] [ drawjoins :webstartgap :weblength :i*:angle ] MAKE "alen 20 FOR [i 1 10] [ MAKE "forangle 0 FOR [i 1 :sides+1] [ ;FOR [i 1 3] [ MAKE "bx :alen * COS 90 - :forangle MAKE "by :alen * SIN 90 - :forangle MAKE "cangle :angle * :i MAKE "cx :alen * SIN :cangle MAKE "cy :alen * COS :cangle ;print [:bx :by :cx :cy :forangle :cangle] drawincircle :alen :bx :by :cx :cy :forangle MAKE "forangle :forangle + :angle ] MAKE "alen :alen * 3 / 2 ] pu setheading 0 setxy 0 0
Your browser doesn't support canvas tags.
Notifications
Mark all as read
unread
x
j2message
x
j2stars
x
j2homework
x
myfiles
x
j2journal
x
Loading...