# How to create 3-color-manipulator

One of the useful tips of creating an arrow in HOOPS Visualize is to use Polycylinder geometry. You can get the sample code at InsertNormalIndicator mothod in CuttingSectionOperator class. The following sample source code would give you an idea of how to create an impressive manupulator.

Translation Arrow Method would go like this.

``````//////////////////////////////////
void CHPSView::
InsertTransArrow(Point Origin, Vector Dir, double dLength, double dRadius, SegmentKey indicator_seg)
{
PointArray pts(6);
double dArrowTop = dLength + dRadius * 6;
double dArrowBottom = dLength + dRadius * 2;
pts[0] = Origin + dArrowTop * Dir;
pts[1] = Origin + dArrowBottom * Dir;
pts[2] = pts[1];
pts[3] = pts[1];
pts[4] = pts[1];
pts[5] = Origin;

}
``````

Rotational Arrow Method would go like this.

``````//////////////////////////////////
void CHPSView::
InsertRotArrow(Point Origin, Vector UDir, Vector VDir, double dLength, double dRadius, SegmentKey indicator_seg)
{
int i = 0;
PointArray pts(13);

double dCoordU;
double dCoordV;
double M_PI = 3.141592;

for (i = 0; i < 9; i++)
{
dCoordU = dLength * cos(M_PI / 2 * i / 8);
dCoordV = dLength * sin(M_PI / 2 * i / 8);
pts[i + 2] = Origin + dCoordU * UDir + dCoordV * VDir;
}

pts[1] = pts[2];
pts[0] = pts[1] - dRadius * 8 * VDir;
pts[11] = pts[10];
pts[12] = pts[11] - dRadius * 8 * UDir;

}
``````

You can call the following code from Sandbox.

``````SegmentKey indicated_key = GetCanvas().GetAttachedLayout().GetAttachedView().GetSegmentKey();

double dLength = 20.0f;
Point Origin = Point(0, 0, 0);
Vector XAxis = Vector(1, 0, 0);
Vector YAxis = Vector(0, 1, 0);
Vector ZAxis = Vector(0, 0, 1);

SegmentKey redArrowKey = indicated_key.Subsegment("red");
InsertRotArrow(Origin, XAxis, YAxis, dLength, dRadius, redArrowKey);
redArrowKey.GetMaterialMappingControl().SetFaceColor(RGBAColor(1, 0, 0, 1));

SegmentKey greenArrowKey = indicated_key.Subsegment("green");