3. Constrain Segments to Integer Length and to 5° Intervals

Acknowledgement: [url=https://www.geogebra.org/u/michael+borcherds]Michael Borcherds[/url] "[url=https://ggbm.at/wf6a36ak]Demo: constrain a Segment to 15° intervals[/url]"
[u]To constrain AB to integer length[/u][br][b]B = Point(Sequence(A + (i, 0), i, 1, 20, 1))[/b][br][br][u]To constrain AC to integer length[/u][br][b]C1=(3,3)[/b] (C1 is a free point of any coordinates)[br][b]u = [/b][b]Vector(A, C1)[br]UPoints = Sequence(A + i UnitVector(Segment(A, C1)), i, 1, 20, 1)[br]C = DynamicCoordinates(C1, x(ClosestPoint(UPoints, C1)), y(ClosestPoint(UPoints, C1)))[/b][br][b]uCopy = (3,3) [/b] (uCopy is a free vector of any value)[br][br]Scripting | On Update of the following objects: [br]u: [b]SetValue(uCopy, u)[/b][br]A: [b]SetValue(C1,A+uCopy) [/b][br]The purpose of the scripting is to preserve the position of C when A moves.[br][br][u]To constrain BC' to 5° [u]interval[/u][/u][br][b]C2=(6,6)[/b] (C2 is a free point of any coordinates)[br][b]v = Vector(B, C2)[br]VPoints = Sequence((x(B) + Length(v) cos(t°), y(B) + Length(v) sin(t°)), t, 0, 355, 5)[br]C' = DynamicCoordinates(C2, x(ClosestPoint(VPoints, C2)), y(ClosestPoint(VPoints, C2)))[/b][br][b]vCopy = (6,6)[/b] (vCopy is a free vector of any value)[br][br][i]Scripting|OnUpdate[/i] of the following objects: [br]v: [b]SetValue(vCopy, v)[/b][br]B: [b]SetValue(C2,B+vCopy)[/b][br]  [b]SetValue(C1,A+uCopy)[/b][br]A:[b] SetValue(C1,A+uCopy)[br]  SetValue(C2,B+vCopy) [/b][br]The purpose of the scripting is to preserve the position of C' and C when B or A moves.[br][br][u]To snap C and C' to the 2 intersections G and G'[/u][br][i]Scripting|OnUpdate [/i]of:[br]C:  [b]SetValue(C, If(Distance(C,G)<d, G, If(Distance(C,G')<d, G', C)))[br][/b]C': [b] SetValue(C', If(Distance(C',G)<d, G, If(Distance(C',G')<d, G', C')))[br][/b]where [b]d=0.3[/b] is the distance less than which the point would be snapped to G or G'.

Information: 3. Constrain Segments to Integer Length and to 5° Intervals