Constructing the Applet from Scratch (For Developers)
This code creates a "snapping" effect that helps users easily construct a perfect equilateral triangle.
In simple terms, the code says: "If the user drags the vertex A very close to a pre-calculated perfect spot (A_1 or A_2), then automatically move A to that exact spot."
How It Works
This script runs continuously in the
OnUpdate tab for point A, meaning it checks the condition every time A is moved.- The Target Points (
A_1andA_2): Before writing this script, the developer would have created two hidden points,A_1andA_2. These points represent the two mathematically perfect locations where vertexAwould form an equilateral triangle with the other two vertices (let's call themBandC). - The Snapping Zone: The
Distance(A, A_1) < 0.2part creates an invisible "snapping zone" or radius around the target pointA_1. The number0.2is the threshold; you can make it larger for a more accurate snap or smaller for greater precision. - The Action:
If(Distance(A, A_1) < 0.2, SetValue(A, A_1)): This line checks if the draggable pointAhas entered the snapping zone around the first target pointA_1. If it has, theSetValue(A, A_1)command is executed, which instantly movesAto the exact coordinates ofA_1, creating a perfect equilateral triangle.- The second line does the exact same thing for the other possible target point,
A_2.
A_1 and A_2 as having small, invisible magnets. When you drag the vertex A close enough, it gets pulled in and locks perfectly into place.How to Construct the Perfect Spots (A_1 and A_2)
There are a few ways to create these hidden target points. The most classic method uses intersecting circles:
- First Circle: Select the Circle tool. Create a circle with its center at point B and its radius extending to point C. This ensures every point on this circle is the correct distance from B.
- Second Circle: Create another circle with its center at point C and its radius extending to point B.
- Find the Intersections: The two points where these circles intersect (
A_1andA_2) are the only two locations in the plane that are the correct distance from both B and C to form an equilateral triangle.
s is (s √3) / 2. So, you would construct a circle on the perpendicular bisector with a radius of (length of base * √3) / 2 to find the perfect spots. The two-circle method is often simpler to construct in GeoGebra.