I am trying to get the 16 equidistant point on ellipse (equal arc length along the ellipse).
Using some research, I am able to get the angle from which I can get those point by drawing a straight line and getting the intersection point but unable to find the length of line to be drawn from the center. I have also explored https://math.stackexchange.com/questions/172766/calculating-equidistant-points-around-an-ellipse-arc but getting confused in formula
What is the value of φ here?
Can anyone please help me there on getting the points. Thanks
We can define (axis-aligned) ellipse parametrization as
x = a * cos(φ)
y = b * sin(φ)
where parameter φ has range 0..2*Pi.
Resulting point (x,y) is situated at angle θ relative to the ellipse center. Your linked post shows formula for θ/φ transformation.
Note - θ is real angle, φ is not!, it is just parameter.
You perhaps don't need θ here. To solve the problem, you have to find ellipse circumference length L using elliptic integral for φ = 2*Pi (numerically).
Then find φ values corresponding to arc length L/16, 2*L/16...15*L/16 - numerically again, and calculate corresponding point coordinates from the parametrization equations.
Related
I am developing a code in python to check whether a sphere having a center at (x, y, z) coordinates and with radius R, intersects the cube of dimension one, i.e., l = 1, b = 1, h = 1. As mentioned above, I want to know if the sphere intersects the cube at any point or direction, or proportion.
I have a list of sphere coordinates (x,y,z) that must be checked for the intersection. I had done some research on it but couldn't clear my doubts regarding how to approach this example.
I would love to know both the math and coding part of it. Can someone please help me solve it..??
Edit: Cube is axis aligned and placed at the origin.
To reveal a fact of intersection, you can calculate distance from cube to sphere center and compare it with sphere radius. 2D case is described here, it could be easily extended to 3D case.
Get cube center as (rcx, rcy, rcz) and find coordinate differences from cube center to sphere center
dx, dy, dz = x - rcx, y - rcy, z - rcz
Let SquaredDist = 0, and for every coordinate make:
t = dx + 0.5 # 0.5 is half-size of your cube
if t < 0:
SquaredDist += t * t
else:
t = dx - 0.5
if t > 0:
SquaredDist += t * t
finally compare SquaredDist with R*R
Some explanation to comment:
Look at the picture in linked answer. For rectangle ABCD we have center G and coordinate differences GK and GJ, they include half of width and half of height. Squared distance (EC here) is sum of squared distances to proper side lines (planes in 3D case). When the closest (to sphere center) point is cube corner, we take into account three planes, when closest point lies at the edge - we take into account two planes, when closest point lies at facet - we take into account only one plane, and when sphere center is inside - SquaredDist remains zero.
Once again I am in over my head so please bear with me.
I have a B-spline (imported from Solidworks) that I can analyze with geomdl in python.
From geomdl I can extract the first and second derivatives as well as the tangent, normal, and binormal vectors for any given point on the spline.
From there I can calculate the curvature at that point from the first and second derivatives.
However I am not able to determine which way the curve is turning.
I would like to find the point that is at the center of curvature of current point of interest on the bspline.
I 'think' that the tangent vector and the normal vector both lie on the osculating plane of interest. The cross product would then give me the normal to the osculating plane. However I can not make this work.
At a minimum I need to know which way the curve is bending. i.e. CW or CCW.
But if I have the point at the center of curvature I would know pretty much everything about that point.
Is this correct?
To restate the question:
Given a point, the derivatives of the curve at that point, and and the Tangent, Normal, and BiNormal vectors, how do I find the center of curvature?
Given a parametric curve C(t) and the first and 2nd derivatives C'(t) and C"(t), the curvature vector can be found
K(t) = m1*C"(t) - m2*C'(t)
where
m1 = 1.0/||C'(t)||^2 and m2 = m1*m1 * C'(t) \dot C"(t).
From K(t), you can find the radius of curvature R(t) as
R(t) = K(t)/||K(t)||^2
and then the center of curvature is C(t)+R(t).
I'm scripting in python for starters.
Making this example simple, I have one edge, with uv Coordinates of ([0,0],[1,1]), so its a 45 degree angle. I have another edge that is ([0,0],[0,1]) so its angle is 0/360 degrees. My goal is to compare the angles of those two edges in order to get the difference so I can modify the angle of the second edge to match the angle of the first edge. Is there a way to do this via vector math?
Easiest to reconstruct and thus constructively remember is IMO the complex picture. To compute the angle from a=a.x+i*a.y to b=b.x+i*b.y rotate b back by multiplying with the conjugate of a to get an angle from the zero angle resp. the positive real axis,
arg((a.x-i*a.y)*(b.x+i*b.y))
=arg((a.x*b.x+a.y*b.y)+i*(a.x*b.y-a.y*b.x))
=atan2( a.x*b.y-a.y*b.x , a.x*b.x+a.y*b.y )
Note that screen coordinates use the opposite orientation to the Cartesian/complex plane, thus change use a sign switch as from atan2(y,x) to atan2(-y,x) to get an angle in the usual direction.
To produce a vector b rotated angle (in radians) w from a, multiply by cos(w)+i*sin(w) to obtain
b.x = cos(w)*a.x - sin(w)*a.y
b.y = cos(w)*a.y + sin(w)*a.x
You will have to rescale to get a specified length of b.
I have an issue that I can't seem to solve. I have already acquired data from another source and created 2 polynomials that are identical in shape but not in orientation, that is one is rotated x degrees compared to the other, and if you rotate the graph x degrees back they will match.
I have already taken the derivative of both of the graphs at a certain point.
I would like to graph these slopes onto a unit circle on a polar graph, and somehow find the angle difference between these two line segments of slope i and j that extend from the origin.
I'm fairly new to python so I so not know how to begin plotting these in polar or finding a way to determine the angle difference. I know that by hand, you can take the inverse tangent but that will only give you a range from +90 to -90. I would like my number to fall in the range from 0 to 360 for rotation.
Any help is appreciated. If this isn't enough info or if it isn't clear enough I can provide more.
I have a set of GPS coordinates in decimal notation, and I'm looking for a way to find the coordinates in a circle with variable radius around each location.
Here is an example of what I need. It is a circle with 1km radius around the coordinate 47,11.
What I need is the algorithm for finding the coordinates of the circle, so I can use it in my kml file using a polygon. Ideally for python.
see also Adding distance to a GPS coordinate for simple relations between lat/lon and short-range distances.
this works:
import math
# inputs
radius = 1000.0 # m - the following code is an approximation that stays reasonably accurate for distances < 100km
centerLat = 30.0 # latitude of circle center, decimal degrees
centerLon = -100.0 # Longitude of circle center, decimal degrees
# parameters
N = 10 # number of discrete sample points to be generated along the circle
# generate points
circlePoints = []
for k in xrange(N):
# compute
angle = math.pi*2*k/N
dx = radius*math.cos(angle)
dy = radius*math.sin(angle)
point = {}
point['lat']=centerLat + (180/math.pi)*(dy/6378137)
point['lon']=centerLon + (180/math.pi)*(dx/6378137)/math.cos(centerLat*math.pi/180)
# add to list
circlePoints.append(point)
print circlePoints
Use the formula for "Destination point given distance and bearing from start point" here:
http://www.movable-type.co.uk/scripts/latlong.html
with your centre point as start point, your radius as distance, and loop over a number of bearings from 0 degrees to 360 degrees. That will give you the points on a circle, and will work at the poles because it uses great circles everywhere.
It is a simple trigonometry problem.
Set your coordinate system XOY at your circle centre. Start from y = 0 and find your x value with x = r. Then just rotate your radius around origin by angle a (in radians). You can find the coordinates of your next point on the circle with Xi = r * cos(a), Yi = r * sin(a). Repeat the last 2 * Pi / a times.
That's all.
UPDATE
Taking the comment of #poolie into account, the problem can be solved in the following way (assuming the Earth being the right sphere). Consider a cross section of the Earth with its largest diameter D through our point (call it L). The diameter of 1 km length of our circle then becomes a chord (call it AB) of the Earth cross section circle. So, the length of the arc AB becomes (AB) = D * Theta, where Theta = 2 * sin(|AB| / 2). Further, it is easy to find all other dimensions.