2 Attachment(s)
given one point, calculate remaining coordinates of square/triangle inside a circle..
Attachment 29615Attachment 29616
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?
thanks!
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Hey wilbsy.
Have you taken a calculus course? If you know calculus you can solve this through an optimization problem.
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Quote:
Originally Posted by
Plato Here are the coordinates of the other vertices:
.
Also note that through the formulas for the cosine and sine of a sum, the other coordinates are expressible through the given ones, so there is no need to compute θ explicitly. This works whether xy = 0 or not.
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
posting error... lo siento.
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Quote:
Originally Posted by
emakarov Also note that through the formulas for the cosine and sine of a sum, the other coordinates are expressible through the given ones, so there is no need to compute θ explicitly. This works whether xy = 0 or not.
could you elaborate with pseudo code?
thanks
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Quote:
Originally Posted by
chiro Hey wilbsy.
Have you taken a calculus course? If you know calculus you can solve this through an optimization problem.
i took some precal years ago, but even in that my working knowledge is definitely subpar. i'd be curious to know the calculus approach to this problem... i'm using these equations in a program, so it's always good to know all the potential methods in order to optimize the code.
would it be appropriate to continue on this thread? or should we move it over to the calculus subforum?
thanks!
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Quote:
Originally Posted by
wilbsy could you elaborate with pseudo code?
If you rotate a point (x, y) by radians counterclockwise around the origin (in the case of the triangle, and for the square ), the new coordinates are and . In matrix form,
.
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.
Quote:
Originally Posted by
wilbsy i'd be curious to know the calculus approach to this problem...
Here calculus can be used only to make sure that the vertices of the largest triangle lie on the circle, which is obvious anyway.
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Hello, wilbsy!
Quote:
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

Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Quote:
Originally Posted by
Soroban With a square, no trigonometry or calculus is needed.
Suppose vertex
is in Quadrant I with coordinates
Then the other vertices are easily located.
wow, the simplicity is striking... seems too easy to be true. ;)
thanks!
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Quote:
Originally Posted by
wilbsy seems too easy to be true.
It is too easy and wrong. It does not give you a square.
The method does give a rectangle the sides of which are parallel to the principal axises.
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Quote:
Originally Posted by
Plato It is too easy and wrong. It does not give you a square.
The method does give a rectangle the sides of which are parallel to the principal axises.
Whereas I think that Soroban should have provided a method or at least hints to get to his solution we can calculate that the quadrilateral has two pairs of parallel sides, the sides all meet at right angles, and all sides have the same length...these points form a square.
Dan
Re: given one point, calculate remaining coordinates of square/triangle inside a circ
Quote:
Originally Posted by
topsquark Whereas I think that Soroban should have provided a method or at least hints to get to his solution we can calculate that the quadrilateral has two pairs of parallel sides, the sides all meet at right angles, and all sides have the same length...these points form a square.
Two of us saw the post as a graphics programming problem. That was to focus of replies #3 & #8.
As for the other matter, good luck in changing behavior there.