Reputation: 5731
Considering the class:
public class Point3D
{
public double X;
public double Y;
public double Z;
public Point3D(double x, double y, double z)
{
X = x;
Y = y;
Z = z;
}
public double DistanceTo(Point3D to)
{
double dX = Math.Abs(to.X - X);
double dY = Math.Abs(to.Y - Y);
double dZ = Math.Abs(to.Z - Z);
return Math.Sqrt(dX * dX + dY * dY + dZ * dZ);
}
}
And the class:
public class Segment
{
public Point3D From;
public Point3D To;
public double? Radius;
public Segment(Point3D from, Point3D to, double? radius)
{
From = from;
To = to;
Radius = radius;
}
public double Length
{
get
{
double straightLength = From.DistanceTo(To);
if (Radius == null)
return straightLength;
if (Radius < straightLength/ 2d)
throw new Exception();
// Compute the arcuate segment length
}
}
}
I would like to compute the length of the arc (with Radius
) passing through From
and To
3D points.
Some help will be welcome!
Upvotes: 2
Views: 934
Reputation: 111
One more reference: from math.stackexchange
S=length of the arc = r*theta, where r= radius and Cos(theta)=(dotproduct of 2 vectors)/(product of the modulus of those vectors)
Upvotes: 0
Reputation: 23324
According to http://mathworld.wolfram.com/IsoscelesTriangle.html
straightLength / 2 = Radius * sin( 1/2 * angle)
Therefore:
angle = 2 * arcsin( straightLength / 2 / Radius)
and
arcLength = Radius * angle;
Upvotes: 2