Jump to content
Developer Wiki and Function Reference Links ×

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!

 

 

Link to comment

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. 😉

 

 

 

  • Laugh 1
Link to comment

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.

  • Like 3
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...