I can't figure out how to find $(s_x, s_y)$ (see picture, the blue marked intersection). I have $\alpha$, and the square is perfectly inside the square. Assume the radius is 1, since that isn't very important. Hobby programmers aren't the best at math I'm guessing, heh.. Sorry if this is very trivial.
Asked
Active
Viewed 1,069 times
2 Answers
2
$(x,y) = (\frac {\cos t}{|\cos t| + |\sin t|}, \frac {\sin t}{|\cos t| + |\sin t|})$
Doug M
- 57,877
-
Does (x, y) represent any point on the side of a square inside circle? – Ashokan Sivapragasam Mar 31 '20 at 17:20
2
As you know the angle, the slope of the line is known, and it passes through origin. SO its equation is $y= \tan(2\pi-\alpha) x$.
Now you have to find the intersection of this line with the side of the square in the third quadrant. This side is the that line which passes through $(0,-r)$ and $(-r, 0)$, with $r$ the radius of the circle which I assume you are given. SO the equation for that is $ y =-x -r$.
Now solve the two equations in 2 unknowns $x,y$ to get the point of intersection in terms of $\alpha$ and $r$
P Vanchinathan
- 19,504
-
Sadly this doesn't help me since for the program I am writing I need to be able to calculate the point while the angle can be anything, not just the third quadrant. But thank you nevertheless! :) – snowflake Aug 04 '16 at 11:52
-
No need to be sad. It is very much possible to program. Use a switch statement of C (or if you are writing in Python use if, with elif, elif . . ) to cover all the cases of 4 quadrants. It is not difficult to modify the equations for all the four cases. Let me do that for 2nd quadrant: Eqn of the side of square : $ y = x+1$) – P Vanchinathan Aug 04 '16 at 12:04
-
