Bojo-triangle-inscribed (advanced)

Help Contents Examples Bojo-triangle-inscribed (advanced)
Bojo-Triangle (advanced) Butterfly (simple)

Bojo-triangle-inscribed (advanced)

This advanced example shows how to make a rubber band triangle ABC with the inscribed circle.

run "geomland

make "line    se :line [make local "pattern "xo]
make "dotsegment se :segment [make local "pattern "xoo]
make "segment se :segment [make "color rgb_ 1 0 0, make local "width 3 ]
make "angle se :angle [make "radius 10]

ob "A point 200 0
ob "B point -100 0
ob "C point 100 100

ob "ab segment :A :B
ob "bc segment :B :C
ob "ca segment :C :A

ob "sab line :C 90+((heading :bc)+(heading :ca))/2
ob "sbc line :A 90+((heading :ab)+(heading :ca))/2

ob "M isec :sab :sbc
ob "D isec line :M 90+(heading :ab) :ab

ob "K circle :M :D
ob "m dotsegment :D :M
ob "ang angle :M :D :A

ob "A initial :ab
ob "A final :ca

ob "B initial :bc
ob "B final :ab

ob "C initial :ca
ob "C final :bc

make "Asp 200/0.53
make "dragobject []

to onmouseup :x :y
	make "dragobject []
end

to onmousemove :x :y

	make "x :Asp*:x
	make "y :Asp*:y

	if :dragobject<>[]
	[
		if point? :(:dragobject)
		[
			make :dragobject point :x :y 
		]
		[
			make local "s :(:dragobject)
			make local "p (point :x :y)-:dragpoint

			make :dragobject segment :s.initial+:p :s.final+:p

			make [hidden] "dragpoint point :x :y
		]
	]
end

to setdragobject :objname :x :y

	make "dragobject :objname
	make "dragtype type :(:dragobject)
	make "dragx :x
	make "dragy :y
end

to onmousedown :x :y

	make "x :Asp*:x
	make "y :Asp*:y

	eps (-1)
	make [hidden] "dragpoint point :x :y

	if (:A.x=:x) and (:A.y=:y) [setdragobject "A :x :y]
	if (:B.x=:x) and (:B.y=:y) [setdragobject "B :x :y]
	if (:C.x=:x) and (:C.y=:y) [setdragobject "C :x :y]

	eps (-1)
	if :dragobject=[]
	[
		if 180=angle3 :A :dragpoint :B [setdragobject "ab :x :y]
		if 180=angle3 :B :dragpoint :C [setdragobject "bc :x :y]
		if 180=angle3 :C :dragpoint :A [setdragobject "ca :x :y]
	]
	eps (10)
	onmousemove :x/:Asp :y/:Asp
end

Bojo-Triangle (advanced) Butterfly (simple)