Jump to content
Developer Wiki and Function Reference Links ×

vectorscript: creating arcs with 3 points


Hippocode

Recommended Posts

I'm trying to create small arcs from point A to B.

With the ArcTo function, it always uses the mode "arc by radius". Is there a way to select any of the other modes while running a script ?.

And if there is any other option then using an arc it would be even better, as it should be a bit curved instead of an arc..

Link to comment
These 3 create a different kind of arc, you could try them and see which one fits you best:

ArcTo();

CurveThrough();

CurveTo();

If the above didn't help, you can also adjust your polyline after creation:

SetPolylineVertex();

Smooth();

Well I hoped to do so without creating a polyline but I'll just settle with it. Curvetrough did it ;)

Link to comment
  • 2 weeks later...

Got into a problem on creating polyline arcs.

Seems I can get as many curves as I want, but only in a couple directions.

I'm trying to create something as in the added image.

Step 1-3 works great, step 4 draws a line instead of the arc.

Doing the reverse will have the same result, only the first arc succeeds, the second one in the opposite direction becomes a line.


beginpoly;
AddPoint(P1);
ArcTo(P2);
AddPoint(P2);
AddPoint(P3);
ArcTo(P4);
AddPoint(P4);
endpoly;

Edited by hippothamus
Link to comment
I think you need to add another point back to P1, otherwise VW will close the poly for you and that will by default be a line.

If you don't want to close the poly, you need to add the Procedure OpenPoly; before you start drawing your poly.

Adding P1 shouldn't be a problem, as that is a simple line between P1 and 4. If I don't make it, the poly will close it anyway.

But so I did, and this is the result: the small arc at the bottom is still a line

		beginpoly;
		{P1}
		AddPoint(length,Diameter/2);
		{P2}
		ArcTo(length+diameter+InnerRadius,Diameter/2,Diameter+InnerRadius);
		AddPoint(length+diameter+InnerRadius,-Diameter/2-InnerRadius);
		{P3}
		AddPoint(length+InnerRadius,-Diameter/2-InnerRadius);
		{P4}
		ArcTo(length,-Diameter/2,InnerRadius);
		AddPoint(length,-Diameter/2);
		{P1}
		AddPoint(length,Diameter/2);
	endpoly;

Link to comment
You need more data to define the direction and radius of the arcs. How else will VS know to draw a CW or CCW arc segment? Three points on the arc segment, or two points and a radius are typical inputs for your function.

Raymond

I guess its that, but don't I do that with the following:

			ArcTo(length,-Diameter/2,InnerRadius);

Its the same sort of code as the first arc that does work. It just doesn't work if an arc is in the opposite direction for some reason.

Link to comment

Hello Wouter,

???The problem you are having is in matching the points in your diagram to the points you need in VectorScript to draw the shape. Your shape requires 6 points, not 4 ? the 4 you have on your diagram and 2 more to help define the arcs.

???The ARCTO points are virtual points and do not lie on your finished path. You got the first one right, but you did not follow the same method for defining the second ARCTO point

???One easy way to see how to draw a complex shape with VS is to draw it manually in a blank file, then use the Export VS... command under the File->Export menu. Open the text file with an editor. The object creation code is closer to the bottom of the file than to the top.

???Another thing that might make your procedure easier to write is to choose variable names that correspond to the physical parts of your shape; alwasy more difficult than it seems. I reworked your code example and changed some variable names, and added one to hopefully make the code easier to follow. Here's what I think you are trying to do. I labeled the points on your diagram as P1-P4 and I labeled the two ArcTo points as PA & PB. This code only draw a 90? section. Different angle sections can be drawn, but more math is needed to get the ARCTO points defined.

PROCEDURE xxx;
{ This code sample will draw a 90? cross section of a pipe wall. }
CONST
HorOffset = 5;		{ was your LENGTH }
Thickness = 3;		{ was your DIAMETER }
InnerRadius = 2;
OuterRadius = Thickness + InnerRadius;

BEGIN
ClosePoly;
BeginPoly;
	{P1}
	AddPoint(HorOffset, Thickness/2);
	{PA - the ARCTO point is not on the path, it is a point that is on both tangent lines through P1 & P2.}
	ArcTo(HorOffset + OuterRadius, Thickness/2, OuterRadius);
	{P2}
	AddPoint(HorOffset + OuterRadius, -Thickness/2 - InnerRadius);
	{P3}
	AddPoint(HorOffset + InnerRadius, -Thickness/2 - InnerRadius);
	{PB - the ARCTO point is not on the path, it is a point that SHOULD BE on both tangent lines through P3 & P4.}
	ArcTo(HorOffset + InnerRadius, -Thickness/2, InnerRadius);
	{P4}
	AddPoint(HorOffset, -Thickness/2);
EndPoly;
END;
Run(xxx);

???It is also possible to draw the shape with a 3-Point-Arc method. Here's another example, but without your variables. The points are hard coded.

PROCEDURE xxx;
{ Example using PointOnArc method, or 3-Point Arc to draw a 90?cross section of a pipe wall }
BEGIN
ClosePoly;
BeginPoly;
	{ P1 }
	MoveTo(0, 4);
	{ PA - point on the arc between P1 and P2 }
	Add2DVertex(2.82842712474619, 2.828427124746191, 4, 4);
	{ P2 }
	LineTo(4, 0);
	{ P3 }
	LineTo(2, 0);
	{ PB - point on the arc between P3 and P4 }
	Add2DVertex(1.414213562373095, 1.414213562373095, 4, 2);
	{ P4 }
	LineTo(0, 2);
EndPoly;
SysBeep;
END;
Run(xxx);

HTH,

Raymond

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