How to find both of the degrees and length of the hypotenuse in a circle if were stretched?

38 Views Asked by At

I'm trying to calculate the degrees of an angle and the length of the hypotenuse if they were stretched/scaled horizontally or vertically.

Here's a picture to demonstrate.

a = width
b = height
c = length of hypotenuse
α = degrees

enter image description here

I want to find out if there is a possible way to cut down the math I have for calculating the stretched angle below.

Converting degrees to Vector2 like format, and apply the scale.
$\ \theta=\alpha\frac{π}{180} $
$\ x=\cos(θ)a $
$\ y=\sin(θ)b $

Then convert it back to degrees.
$\ \alpha=\operatorname{atan2}(y, x)\frac{180}{\pi} $

Sorry if the way I write my equations is weird, I only have a shallow understanding in writing equations.

Here's an example in code:

void ScaleAngle(float degress, Vector2 size)
{
    // Convert degrees to Vector2 and apply scale
    float theta = (degress - 90) * (Mathf.PI / 180);
    Vector2 v = Vector2(cos(theta), sin(theta)) * size;

    // Convert Vector2 back to degrees
    float a = atan2(v.y, v.x) * (180 / Mathf.PI) + 90;
    
    return a;
}

I don't know where to start with finding the length of the hypotenuse with the scaling in mind, sorry.

Thank you.

2

There are 2 best solutions below

3
On BEST ANSWER

You have found out the parametric representation of points which form an ellipse, where $$x=acosθ,y=bsinθ$$

General equation of an ellipse is $$\frac{x²}{a²} + \frac{y²}{b²} = 1 $$ I think you mistyped the formula in your question for $θ$. $$tan θ= \frac{a}{b}×\frac{y}{x}$$ Or $$θ=tan^{-1}\frac{ay}{bx}$$

And $$c=\sqrt{x²+y²}=\sqrt{a²cos²θ+b²sin²θ}$$

Other than that, it's all correct. This answer to another question proves the parametricity of a and b

1
On

Your computation is correct and doesn't really simplify any further. $x$ and $y$ are the scaled horizontal and vertical values of the point on the ellipse relative to the center, and the new angle $\alpha$ is given by your formula. The value of $c$ is simply $\sqrt{x^2 + y^2} = \sqrt{a^2 \cos^2 \theta + b^2 \sin^2 \theta}$.