First before I get ahead of myself and not too get too in depth for now but in general is okay to think of GetFirstDerivative() as a First Derivative test as it looks at the points just to each side and returns a vector tangent at that point.(Which Tony already better explained).
Just playing with code from
Link posted previously.
I know this is not the way to do it but I just do not remember, or to state it correctly instead of actually learning the material for Calculus I,II,III I just remembered what I had needed to pass the test(I really regret it now).
Just messing around with and to my suprise for straight curves functions much like a block with alignment parameter but could someone point in the right direction or to material to help understand the math involved.
This falls flat on its face in numerous situations
if (Bref.Position.X < pnt.X || Bref.Position.Y < pnt.Y)
{
dir = dir.Negate();
}
case 1:
Bref.Position = mPosition.TransformBy(UCS);
if (mIsDynamicAlignment)
{
if (!mObjectIdToAlignWith.IsNull)
{
if (mObjectIdToAlignWith
.ObjectClass.IsDerivedFrom(RXClass
.GetClass(typeof(Curve
)))) {
Curve curve = (Curve)Bref.Database.TransactionManager.TopTransaction.GetObject(mObjectIdToAlignWith, OpenMode.ForRead);
Point3d pnt = curve.GetClosestPointTo(Bref.Position, false);
Vector3d dir = curve.GetFirstDerivative(pnt).TransformBy(UCS.Inverse());
if (Bref.Position.X < pnt.X || Bref.Position.Y < pnt.Y)
{
dir = dir.Negate();
}
mAlignmentAngle = Vector3d.XAxis.GetAngleTo(dir, Vector3d.ZAxis);
Bref.Rotation = mAlignmentAngle mAngleOffset;
}
}
else
{
Bref.Rotation = 0.0;
}
foreach (DynamicBlockReferenceProperty props in Bref.DynamicBlockReferencePropertyCollection)
{
if (props.PropertyName == "TextRotation")
{
props.Value = Bref.Rotation == 0.0 ? 0.0 : ((360.0 - (Bref.Rotation * (180.0 / System.Math.PI))) * (System.Math.PI / 180.0));
}
}
}