On a line segment, how do I calculate the coordinates at a specific distance from the start point? - coordinates

Given two points (x1, y1) and (x2, y2), how do I calculate the co-ordinates of a specific point (xn, yn) at a specific distance (n) from the start point?
I'm using C#.

Related

helix central axis angle

I have N points in [x,y,z] and this kind of takes a helix shape. Is it possible to find the central axis of such a helix. This is not a regular helix with the central axis as either of global X, Y and Z axis
When I plot the curve looks at a particular angle to the global Z axis.
My aim is to know the angle the central axis is making with the global z axis?
If your N points are dense enough (or equi-distant), the tangential vectors (diff vectors of consecutive points) will form a cone whose direction of the center axis coincides with direction of the helix axis and whose base plane is orthogonal to this axis direction. A projection of the helix into this normal plane will give a circle with a center on the helix axis.
I do not use Matlab as I got aversion to it but based on your plot I would approach this problem like this:
take first 1-2 screws and compute its BBOX
the center point of this BBOX call A
take last 1-2 screws and compute its BBOX
the center point of this BBOX call B
compute helix estimate
So line AB should be very near to your helix axis. Now just find avg or max perpendicular distance to it that is your radius. Use these as initial values for fitting and search around them to minimize error.
Perpendicular distance of any point P to AB can be computed with vector math like this:
U = B-A
V = P-A
W = (U.V)/|U|
D = V-W
dist = |D|
where (U.V) is dot product and |U| is vector length.
fit cylinder/helix more precisely
so just search around initial guess/estimate to minimize avg and or max distance of points and fitted cylinder/helix surface. For more info and examples see:
How approximation search works
[Notes]
If you do not know how to select screws then divide your set to halves and use one for A and second for B ...
if the point density is constant you can compute curve length (sum the lines), count of screws(bumps in any axis) , height of helix (distance between first and last point) and from that infer radius as curve_length = ~sqrt((2*pi*r*screw)^2 + AB_distance^2)
I will assume that:
that the points on the helix are in the array pos with first dimension for time (or step) and second one for the 3 components of the position vector;
the time variable is stored in the array time.
You can calculate the tangent vectors:
Tangent=diff(pos(:,1:3))./(diff(time));
Then take the mean of this:
meanTangent=mean(Tangent);
and you have your axis.

How can I calculate a tangent vector at a point in 3D dimensions?

On the z=0 plane, I have a point A(a1,b1,0). And there is another point B(a2,b2,0) which I consider it as the center of a circle. I connect AB together and then draw a circle with radius AB. There is another point C(a3,b3,c3) in the 3D zone.
How can I find the tangent vector of AC on the circle with radius AB?Ie means that I need to calculate the tangent vector of AC at point A.
If you mean tangent to the circle at point A, then it is unique vector perpendicular to vector AB and is NOT dependent on any other point in 3D like point C. It should be easy to calculate.
On other hand project of AC on the plane is easy to calculate but it is NOT guaranteed to be tangent vector that you are looking for.

How can I compute the diameter of the circle that circumscribes an irregular object?

I want a function to compute and get the diameter of the circle that circumscribes the object. Is there a built-in function in MATLAB to do this? Otherwise, what can I do?
Try this algorithm:
Compute the average x and average y for every point in the irregular object. This is done by taking the x and y component for every point and add them into the total x and total y and then divide by the number of points. This average x and average y point algorithm gives you a non-weighted center of the object.
Use that center point to compute the distance for every point in the irregular object again. Keeping the largest distance as the radius of the object.
Use the center point and the radius to compute the circumference.
I am submitting proof that the distance between the 2 points that are furthest apart in the object fails with a simple triangle. See image below. Also, the big-O notation for computing the two points that are the furthest apart is x^2. The big-O for this algorithm is 2x. The diameter of the circle in the image would be computed as 20; distance between -10,0 and 10,0. A circle of diameter 20 will not encompass the point # 0,-11. Any movement of the circle would automatically remove at least one of the two points used to compute the diameter of the circle because both points are on tangents.
Suppose M is a mask in BW, just do :
[b_x,b_y] = find(bwperim(M)== 1)
Check this function bwperim

How can we map the degree in between two points on an image IN matlab?

We know the center point of an image (say X0, Y0) and also know the observed point coordinates (say X, Y). Then we have to calculate the degree of that point (X, Y) and also the direction of that point. Finally we have to convert it into the value of compass angle.

Plotting 3xN matrix(N number of 3D points) on same graph using matlab

I've a 3xN matrix W where N is 50
W(1,1) is x coordinate of a point
W(2,1) is y coordinate of same point
W(3,1) is z coordinate of same point
Similarly:
W(1,2) is x coordinate of another point
W(2,2) is y coordinate of same point
W(3,2) is z coordinate of same point
....
Now I want to 3d plot all these 3d points on same figure using matlab. How can I plot all these
points on same figure?
Is it possible to plot this matrix using a single function call(in matlab)?
I know that plot3 can be used but it can be used for one graph at a time.
So plot3(v(1,1),v(1,2),v(1,3)); is just a single point. But how do I plot all N points?
Is there an easier and better method?
I guess you can use plot3(w(1,:),w(2,:),w(3,:)).