# Create an Arc with 3 inputs (End points and radius only)

I need to plot an arc with endpoints and radius (3 inputs only), however this function does no exist within rhinoscriptsyntax or rhino.geometry but only as an actual built-in tool. I would sincerely appreciate if anybody has created this function of could assist me with this matter.

Regards,

HMR

``````import Rhino.Geometry as rg
import rhinoscriptsyntax as rs
pt1 = rs.GetPoint("Start of arc")
pt2 = rs.GetPoint("End of arc")
d = pt1.DistanceTo(pt2)
x = (r**2 - (d**2)/4)**0.5
midPt = (pt1+pt2)*0.5
vector = rs.VectorCrossProduct(pt2-pt1, normalVector)
vector.Unitize()
vector *= x
center = midPt - vector
pt3 = ((center-pt1)*2)+pt1
``````

Horacio.py (454 Bytes)

Hi Mahdiyar,

Thanks for the help. I had to modify the function as I am currently using it in a long script where I read data from a csv file. I noticed that the function is not actually plotting correctly. Please have a look at it if possible.

Thanks,

HMR

#Calls specific 2d points from a list and assign them as variables
def GenerateStockRails():

``````StartPoint = TR #(x,y)
EndPoint = TR #(x,y)
#if both y coordinates are the same plot line
if StartPoint == EndPoint:
#plot curves
if StartPoint != EndPoint:

StartPoint = BR #(x,y)
EndPoint = BR #(x,y)

if StartPoint == EndPoint:
if StartPoint != EndPoint:
return (TRC, BRC)
``````

def ArcCreation(pt1,pt2,r):
#pt1 = rs.GetPoint(“Start of arc”)
#pt2 = rs.GetPoint(“End of arc”)
d = rs.VectorLength(rs.VectorCreate(pt1,pt2))
x = (r2 - (d2)/4)**0.5
vector = rs.VectorCrossProduct(rs.VectorSubtract(pt2,pt1), normalVector)
vector.Unitize()
vector *= x
center = rs.VectorSubtract(midPt,vector) ``````import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
def ArcSER(pt1,pt2,r):
d = rs.VectorLength(rs.VectorCreate(pt1,pt2))
x = (r**2 - (d**2)/4)**0.5
vector = rs.VectorCrossProduct(rs.VectorSubtract(pt2,pt1), normalVector)
vector.Unitize()
vector *= x
center = rs.VectorSubtract(midPt,vector)

ArcSER([0,0,0],[0,10,0], 10)``````

Hi,

For all of those that may want to do something similar in the future. Here I attach what worked for me.

def CircleCenter(Pt1,Pt2,R):
if R<0:
ChordVector = rs.VectorCreate(Pt1,Pt2)
ChordLength = rs.VectorLength(ChordVector)
a = ChordLength0.5
x = (R2 - (ChordLength2)/4)**0.5
d = R - x
Diff = rs.VectorSubtract(Pt1,Ptm)
Ptc = [Ptm+(x
Diff)/a,Ptm-(xDiff)/a]
if R>0:
ChordVector = rs.VectorCreate(Pt1,Pt2)
ChordLength = rs.VectorLength(ChordVector)
a = ChordLength
0.5
x = (R2 - (ChordLength2)/4)**0.5
d = R - x
Diff = rs.VectorSubtract(Pt1,Ptm)
Ptc = [Ptm-(xDiff)/a,Ptm+(xDiff)/a]
return (Ptc)

def ArcCreation(Pt1,Pt2,R):
ChordVector = rs.VectorCreate(Pt1,Pt2)
ChordLength = rs.VectorLength(ChordVector)
D = R*2
if ChordLength <= D:
x = (R2 - (ChordLength2)/4)**0.5
d = R - x
Center = CircleCenter(Pt1,Pt2,R)
NegCenter = rs.VectorScale(Center,-1)
Vector = rs.VectorCreate(HalfChordPoint,Center)
UnitVector = rs.VectorUnitize(Vector)
ScaledVector = rs.VectorScale(UnitVector,R)
Pt3 = rs.VectorCreate(ScaledVector,NegCenter)

cORRECTED SCRIPT:

def CircleCenter(Pt1,Pt2,R):
if R<0:
ChordVector = rs.VectorCreate(Pt1,Pt2)
ChordLength = rs.VectorLength(ChordVector)
a = ChordLength0.5
x = (R2 - (ChordLength2)/4)**0.5
d = R - x
Diff = rs.VectorSubtract(Pt1,Ptm)
Center = [Ptm+(x
Diff)/a,Ptm-(xDiff)/a]
elif R>0:
ChordVector = rs.VectorCreate(Pt1,Pt2)
ChordLength = rs.VectorLength(ChordVector)
a = ChordLength
0.5
x = (R2 - (ChordLength2)/4)**0.5
d = R - x
Diff = rs.VectorSubtract(Pt1,Ptm)
Center = [Ptm-(xDiff)/a,Ptm+(xDiff)/a]
return (Center)

def ArcCreation(Pt1,Pt2,R):
ChordVector = rs.VectorCreate(Pt1,Pt2)
ChordLength = rs.VectorLength(ChordVector)
D = R*2
if ChordLength <= abs(D):
x = (R2 - (ChordLength2)/4)**0.5
d = abs® - x