Finding radius of ellipse at angle a? [closed] - math

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I know the centre of an ellipse, x0 and y0. I know its width and height.
How do I get the radius at any given angle from x0/y0?

Its conventional to describe an ellipse, centred at x0,y0, whose axes of symmetry are aligned with the coordinate axes by the equation
(x-x0)*(x-x0)/(a*a) + (y-y0)*(y-y0)/(b*b) = 1
Here a and b are constants that define the size and shape of the ellipse.
To get the width we put y=y0, and then the x values are
x = x0 + a
x = x0 - a
so the width is
w = 2*a
Similarly the height is
h = 2*b
If we have a point x,y on the ellipse and the angle between the x-axis and the vector x0,y0 -> x,y is theta then x,y can be written
x = x0 + r*cos(theta)
y = x0 + r*sin(theta)
We need to find r so that x,y is on the ellipse. Plugging these values into the equation for the ellipse and simplifying:
r = 1.0/hypot( cos(theta)/a, sin(theta)/b)
I'm guessing that by radius you mean the distance between x,y and x0,y0. This is r above

Related

Circle curve angle [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
So I'm trying to make an animation of 2 objects orbiting around one object that we will call the sun. The distance from object 1 to the sun is 2 units and that has a constant angle at which it turns and moves on.
I assume that the farther away from the sun it is the smaller the angle so the bigger the circle, but how would you calculate this angle depending on the distance? Here is a picture:
So let's just talk about how to calculate the X, Y coordinates of an object moving around the origin at a constant distance D and with angular velocity W (angular velocity is the number of degrees per second).
The angle Q that our object will make with the ray beginning at the origin and pointed at the positive X-axis is given by Q(t) = Q0 + Wt, where Q0 is the angle the object makes at time t = 0 (the initial condition). If we assume that the object begins immediately to the right of the origin, Q0 = 0, for instance.
The X, Y coordinates of the object at time t can be found using trigonometry on Q(t):
X(t) = D * cos(Q(t)) = D * cos(Q0 + Wt)
Y(t) = D * sin(Q(t)) = D * sin(Q0 + Wt)
If you have two objects at different distances from the origin/sun, then for the same angular velocity W, the object closer to the origin/sun will move with a slower speed than the one farther away. This is because to move the same number of degrees around a larger circle, the object farther away has longer actual distance to go in the same time. Assuming that the angular velocity is being measured in degrees per second, the object's speed in D's distance units per second can be found as follows:
V = (angular velocity / 360 degrees) * (circumference of circle)
= (W/360) * (2*PI*D)
= 2*PI*D*W/180
So, if you wanted V to be constant rather than W, you could solve this for W in terms of your desired V and D.

How to find coordinates of a chord given one point on a circle [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
Update
I do not think this question is off topic.
The solution provided is what I was looking for and it is a programming solution.
================
I want to know how can I find the coordinates of equal chords from the same point on the circle.
As shown in the image below, I will like to choose a random point on a circle and a random chord angle (in the example its 110 degrees).
I will know the radius (r) of the circle and one randomly selected point (A) on a circle.
Based on this data, I would like to know how can I draw two equal chords from this point (AB and AC) where AB = AC.
Let you have circle center xc, yc, radius R.
At first choose random angle in range 0..2*Pi
aangle = random(2*Pi)
Then A coordinates are
ax = xc + R * Cos(aangle)
ay = yc + R * Sin(aangle)
Now choose random (or you need specific value?) chord angle in needed range and get B, C coordinates
changle = random(3 * Pi / 4)
bx = xc + R * Cos(aangle + changle)
cx = xc + R * Cos(aangle - changle) // note subtraction
and similar for Y-coordinates
If you have A coordinates, you can also rotate them around center
bx = xc + (ax - xc) * Cos(changle) - (ay - yc) * Sin(changle)
and so on

Circumcenter coordinates for a isosceles triangle [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I need to calculate circumcenter coordinates (or at least I hope they're called that) at point C for an isosceles triangle (the circle must be such, that created triangle is). I know the point O (origin), two vectors p and q (length may differ) originating in that point (leading to points P and Q). I also know the radius r of this to be circumscribed circle. When the circle's center is known it should create said green highlighted isosceles triangle. Here is drawing for better understanding:
Update (solution):
Calculates the length of p and q vectors
Normalize them both, and add them together
Normalize this to be OC vector again
Finally extend OC vector from point of origin O to length equivalent to radius r
Thinking geometrically:
normalise vectors p and q, i.e. p = p / |p|, q = q / |q|
add them together
normalise the result
multiply that by r - this is the vector OC
add to O
Steps 1 - 3 simply produce the bisection of the vectors p and q
EDIT this is simplified somewhat compared to my original answer.
The first equation of your system is:
(x_c-x_o)^2 + (y_c-y_o)^2 = r^2
The second one is more convoluted. You must intersect the circumference
(x-x_c)^2+(y-y_c)^2 = r^2
with your two vectors, that have equation rispectively
y = (Q_y/Q_x)*x and y = (P_y/P_x)*x
this gives you the two points of intersection p and q in function of x_c and y_c. Now force hte distance OP and OQ to be equal (you want an isoscele triangle), and you have your second equation.
Solve hte two equation system and you have the formula for x_c and y_c.
Assuming i did the math right, the solution is:
x_c = ((a+b)^2 * r^2) / ((a+b)^2+4)
y_c = (-2*(a+b) * r^2) / ((a+b)^2+4)
where
a = p_y / p_x
b = q_y / q_x

How to get perpendicular vectors given a line segment [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to get point A, B , C, and D?
if AB and CD are perpendicular to p0p1.
Assume p0A, p0B, p1C, and p1D have normalized length
The direction of the line is given by d = normalize(p1 - p0). To calculate a perpendicular vector we can use the cross product with (0, 0, 1). Which results in:
d_left = (-d.y, d.x)
d_right = (d.y, -d.x)
You haven't said how your coordinate system is aligned, so d_left might become d_right and vice versa.
You then get the desired points with:
A = p0 + d_left
B = p0 + d_right
C = p1 + d_left
D = p1 + d_right
Suppose rotate(p,d) is a operator to rotate p vector d angle.
Then if the inclination of p0p1 with positive x-axis is x. Then,
A = p0 + rotate(p1-p0,pi/2)/|p1-p0|
B = p0 + rotate(p1-p0,-pi/2)/|p1-p0|
C = p1 + rotate(p1-p0,pi/2)/|p1-p0|
D = p1 + rotate(p1-p0,-pi/2)/|p1-p0|

How to find the Center Coordinate of Rectangle? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I have drawn a rectangle. I know its (x1,y1) Top Left and (x2,y2) Bottom Right coordinates.. I also have the height h and width w of drawn rectangle.. How can I find the center coordinates (x,y) ?
I am currently using the following formula.
(x,y) = (x2 + x1)/2, (y2+y1)/2
It gives the correct y coordinate but no luck in x.
The center of rectangle is the midpoint of the diagonal end points of rectangle.
Here the midpoint is ( (x1 + x2) / 2, (y1 + y2) / 2 ).
That means:
xCenter = (x1 + x2) / 2
yCenter = (y1 + y2) / 2
Let me know your code.
Center x = x + 1/2 of width
Center y = y + 1/2 of height
If you know the width and height already then you only need one set of coordinates.
We can calculate using mid point of line formula,
centre (x,y) = new Point((boundRect.tl().x+boundRect.br().x)/2,(boundRect.tl().y+boundRect.br().y)/2)

Resources