Have you taken a calculus course? If you know calculus you can solve this through an optimization problem.
two questions, on the same vein...
the radius of the red circle is given, and its center point is always at 0,0.
point A moves, tracing the path of the red circle.
given point A, how would you calculate the remaining point coordinates to form the largest possible square within the red circle?
given point A, how would you calculate the remaining point coordinates to form the largest possible equilateral triangle within the red circle?
If is any point on a circle centered at with radius there is unique equilateral triangle inscribed in the circle with a vertex at .
Suppose that then
The angle is the angle makes with the positive x-axis.
The coordinates of can now be written as
Here are the coordinates of the other vertices: .
In case of the square, do the exact same steps using
would it be appropriate to continue on this thread? or should we move it over to the calculus sub-forum?
Some languages have libraries for 2D drawing that include transformations, in particular, rotation. For example, in Java there is a class AffineTranformation and a function that returns an object of this class that performs rotation. You can use this object to transform individual points, shapes or the entire canvas. This way, you don't necessarily have to understand how matrices inside AffineTranformation work.
The radius of the circle is given, and its center point is at (0,0).
Given point A, how would you calculate the remaining point coordinates
to form the largest possible square within the circle?
With a square, no trigonometry or calculus is needed.
Suppose vertex is in Quadrant I with coordinates
Then the other vertices are easily located.
Code:| D * * * (-q,p)o | * * | * A * | o(p,q) | * | * - - * - - - - + - - - - * - - * | * | (-p,-q)o | * C * | * * | o(q,-p) * * * B |