Rotating and offsetting text

Recommended Posts

I have a parametric path object.  I'm inserting symbols along the object that are tangent to the path.

I also want to insert a string value at each point also tangent to the path and offset a given distance perpendicular to the tangent.

I can insert the string at the point.  Not having any luck rotating the string or offsetting it.  Can someone point me in the right direction?

Can't figure out what function will rotate the text around its center point and what function will move it a given distance perpendicular to point along a path.

BEGIN
BTest := PointAlongPoly(ControlGeometry,(DistanceBetweenPoints * N), PtAlongPath,TangentAtPoint);
TangentAngle := Vec2Ang(TangentAtPoint);
Symbol(MySymbol, PtAlongPath.x, PtAlongPath.y, TangentAngle);

N := N+1;
END;

Thanks!

```Procedure Test;

BEGIN
MoveTo(120,120);
TextRotate(45);
TextVerticalAlign(3);
TextJust(2);
CreateText('Does This Work Michatel??
You should use Vector Math
To Determine the X and Y displacement
That you need to move the text block');

END;

Run(Test);```

I'd probably use Pat's suggestion, but to answer your specific question, you would use HRotate() and HMove().

I was hoping to avoid vector math!!!  🤓

If you already have the Tangent, then getting the perpendicular vector should be easy.  Function Perp will get you the vector perpendicular to the Tangent (You will have to decide you need the positive or negative version).

Vec2Ang will give you the angle. If you know the distance you want to offset the text, the X and Y distances should be just trigonometry.

And I thought you were a Maths Major. 😉

19 minutes ago, Pat Stanford said:

And I thought you were a Maths Major. 😉

Ha!!  Back in those days it was Math was singular. 🙂.

Michael,

Vectors are our friends.

Perp(V);    { is a 90° CW rotation }

Perp(-V);   { is a 90° CC rotation }

UnitVec(Perp(V)) * aDistance;    { scales the vector to exactly the distance you need }

where "aDistance" is any real number.

The position of the text is point P on your path (a Vector not a Point) + your offset vector (UnitVec(Perp(V)) * aDistance).

So:

Voffset := UnitVec(Perp(±Vtan)) * Doffset;   { the distance between the path and the text object }

Ptext := Ppath + Voffset;     { the new position of your text object }

where Ptext, Ppath, Vtan, and Voffset are Vectors and Doffset is a Real, and this assumes you already know Vtan, Doffset, and Ppath.

You can also use SetTextOrientation() to position and rotate your text object.

SetTextOrientation(H, Ptext.x, Ptext.y, Vec2Ang(Voffset), False);

You'll have to play with your angles, but I bet you're only off by a multiple of 90°.

HTH,

Raymond

PS - Embrace your Vectors, but not the pointy ends.

Thanks Raymond!!!

I've been learning about and this tool currently uses unit vectors and point arrays and tangent arrays.  Which somehow never came up while getting a math degree!!!

Great explanation.  It is much clearer now.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×