AB4D Forum

Full Version: How to draw dashed LineArcVisual3D?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
That's me again. I will fill this forum with questions =))

How to draw dashed LineArcVisual3D or any other 3DLine? Is that possible ?
(03-31-2015, 01:09 PM)hatecows Wrote: [ -> ]That's me again. I will fill this forum with questions =))


That is great! Just keep questioning.


It is not possible to add dashed lines with Ab3d.PowerToys. But if you really want to have it, you can add many short lines to create that effect.

You can use the following code (used by LineArc) to get the 3D positions of line arc:

Code:
public static void AddArc3DPoints(Point3D circleCenterPosition,
                                          Vector3D circleNormal,
                                          double radius,
                                          Vector3D zeroAngleDirection,
                                          double startAngle,
                                          double endAngle,
                                          int segments,
                                          Point3DCollection points)
        {
            double angle;
            double angleStep;
            Point3D onePosition;
            Vector3D rightDirection;


            if (startAngle == endAngle)
                return;

            circleNormal.Normalize();
            zeroAngleDirection.Normalize();
            rightDirection = Vector3D.CrossProduct(zeroAngleDirection, circleNormal);


            angleStep = ((endAngle - startAngle) * Math.PI / 180) / segments;

            angle = startAngle * Math.PI / 180;
            for (int i = 0; i <= segments; i++)
            {
                // Get the position in 3D based on the orientation of the circle (circleNormal, zeroAngleDirection)
                onePosition = circleCenterPosition;
                onePosition += Math.Sin(angle) * radius * rightDirection;
                onePosition += Math.Cos(angle) * radius * zeroAngleDirection;

                // Add position
                points.Add(onePosition);

                if (i == segments - 1)
                    angle = endAngle * Math.PI / 180; // this prevent double inprecission
                else
                    angle += angleStep;
            }
        }

This will fill points collection.

After that you can use the Ab3d.Models.Line3DFactory.CreateMultiLine3D method to create multiple short lines (note that the method takes positions collection that define lines with 2 Point3D position - for example line1: positions[0] to positions[1], line2: position[2] to position[3], ...