This might help:
http://paulbourke.net/geometry/circlesphere/
Scroll down to "Equation of a Circle from 3 Points"
Edit: This deals with the edge cases where two points are aligned vertically, two or more points are coincident and if there is anything other than 3 points
circlefrom3points.fmw
I would try this with a PythonCaller.
# PythonCaller Script Example
# Replace feature's geometry with a circle created from its first three vertices.
# Assume the input feature has a geometry having three or more vertices.
# The three vertices should have different coordinates, and any one of them
# should not be on the straight line passing other two vertices.
import fmeobjects
def createCircleFromThreeVertices(feature):
coords = feature.getAllCoordinates()
threeVertices = [fmeobjects.FMEPoint(*p) for p in coords[:3]]
arc = fmeobjects.FMEArc(tuple(threeVertices))
arc.setSweepAngle(360)
feature.setGeometry(fmeobjects.FMEEllipse(arc))
Edit: This deals with the edge cases where two points are aligned vertically, two or more points are coincident and if there is anything other than 3 points
circlefrom3points.fmw
This worked perfectly, thank you!
I would try this with a PythonCaller.
# PythonCaller Script Example
# Replace feature's geometry with a circle created from its first three vertices.
# Assume the input feature has a geometry having three or more vertices.
# The three vertices should have different coordinates, and any one of them
# should not be on the straight line passing other two vertices.
import fmeobjects
def createCircleFromThreeVertices(feature):
coords = feature.getAllCoordinates()
threeVertices = [fmeobjects.FMEPoint(*p) for p in coords[:3]]
arc = fmeobjects.FMEArc(tuple(threeVertices))
arc.setSweepAngle(360)
feature.setGeometry(fmeobjects.FMEEllipse(arc))
Elegant and minimal, I like it. The PythonCaller might also be followed by an ArcStroker if the destination doesn't support arcs.
I would try this with a PythonCaller.
# PythonCaller Script Example
# Replace feature's geometry with a circle created from its first three vertices.
# Assume the input feature has a geometry having three or more vertices.
# The three vertices should have different coordinates, and any one of them
# should not be on the straight line passing other two vertices.
import fmeobjects
def createCircleFromThreeVertices(feature):
coords = feature.getAllCoordinates()
threeVertices = [fmeobjects.FMEPoint(*p) for p in coords[:3]]
arc = fmeobjects.FMEArc(tuple(threeVertices))
arc.setSweepAngle(360)
feature.setGeometry(fmeobjects.FMEEllipse(arc))
This worked great for generating closed arcs (circles) but in attempting to output arcs with a start/end point and changing the sweep angle value it always returns a closed arc having the same start/end point. Its as if the arc.setSweepAngle(x) statement is ignored? What am I missing?
import fmeobjects
def createArcFromTwoVertices(feature):
coords = feature.getAllCoordinates()
twoVertices = [fmeobjects.FMEPoint(*p) for p in coords[:2]]
arc = fmeobjects.FMEArc(tuple(twoVertices),rad,False)
arc.setSweepAngle(sweep_angle)
feature.setGeometry(fmeobjects.FMEEllipse(arc))
This worked great for generating closed arcs (circles) but in attempting to output arcs with a start/end point and changing the sweep angle value it always returns a closed arc having the same start/end point. Its as if the arc.setSweepAngle(x) statement is ignored? What am I missing?
import fmeobjects
def createArcFromTwoVertices(feature):
coords = feature.getAllCoordinates()
twoVertices = [fmeobjects.FMEPoint(*p) for p in coords[:2]]
arc = fmeobjects.FMEArc(tuple(twoVertices),rad,False)
arc.setSweepAngle(sweep_angle)
feature.setGeometry(fmeobjects.FMEEllipse(arc))
Hi @wallace You can create an Arc by 3 Points without Python, using an FMEFunctionCaller:
@Geometry(SET_PROPERTIES, ARC3POINTS,
[<startX>], [<startY>], [<startZ>],
[<midX>], [<midY>], [<midZ>],
[<endX>], [<endY>], [<endZ>])