I am not sure what the correct words are how to ask the question correctly, I cheated to pass Calculus 3.
If I got segment from a polyline the LineSegment3D has a direction property how do I apply that or what do I have to do to translate it?
For example in the pic above what do i have to do with direction vector information to make it rotate with line? I know it is some math but just not coming to me.
Here is the test code thrown together to see how it worked.
public class ConduitGripData : GripData
{
public GripType GripType { get; set; }
public override bool ViewportDraw(Autodesk.AutoCAD.GraphicsInterface.ViewportDraw worldDraw, ObjectId entityId, DrawType type, Autodesk.AutoCAD.Geometry.Point3d? imageGripPoint, int gripSizeInPixels)
{
Point2d glyphSize = worldDraw.Viewport.GetNumPixelsInUnitSquare(this.GripPoint);
Double glyphHeight = (gripSizeInPixels / glyphSize.Y);
Matrix3d e2w = worldDraw.Viewport.EyeToWorldTransform;
Point3d pnt = this.GripPoint.TransformBy(e2w);
Point3dCollection pnts = GlyphPoints(glyphHeight, pnt);
worldDraw.Geometry.DeviceContextPolygon(pnts);
return false;
}
private Point3dCollection GlyphPoints(double glyphHeight, Point3d pnt)
{
Point3dCollection pnts
= new Point3dCollection
(); switch (GripType)
{
case GripType.MidPoint:
pnts
.Add(new Point3d
(pnt
.X - (glyphHeight
* 1.5), pnt
.Y + (glyphHeight
/ 2), pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X - (glyphHeight
* 1.5), pnt
.Y - (glyphHeight
/ 2), pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X + (glyphHeight
* 1.5), pnt
.Y - (glyphHeight
/ 2), pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X + (glyphHeight
* 1.5), pnt
.Y + (glyphHeight
/ 2), pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X - (glyphHeight
* 1.5), pnt
.Y + (glyphHeight
/ 2), pnt
.Z)); return pnts;
default:
pnts
.Add(new Point3d
(pnt
.X + (glyphHeight
* 0.57736), pnt
.Y + glyphHeight, pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X + (glyphHeight
* 1.1547), pnt
.Y, pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X + (glyphHeight
* 0.57736), pnt
.Y - glyphHeight, pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X - (glyphHeight
* 0.57736), pnt
.Y - glyphHeight, pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X - (glyphHeight
* 1.1547), pnt
.Y, pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X - (glyphHeight
* 0.57736), pnt
.Y + glyphHeight, pnt
.Z)); pnts
.Add(new Point3d
(pnt
.X + (glyphHeight
* 0.57736), pnt
.Y + glyphHeight, pnt
.Z)); return pnts;
}
}