Skip to main content
Question

Creating a circle through all vertices of a triangle

  • September 19, 2017
  • 7 replies
  • 83 views

Forum|alt.badge.img

Hi All,

How would I go about creating a circle where the perimeter passes through all three vertices of a triangle?

I've attempted to use the Minimum Spanning Circle Replacer, but this creates a circle based only on the longest side of the triangle.

Any ideas would be greatly appreciated.

Thanks

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

Forum|alt.badge.img

This might help:

http://paulbourke.net/geometry/circlesphere/

Scroll down to "Equation of a Circle from 3 Points"


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • September 19, 2017

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


takashi
Celebrity
  • 7843 replies
  • September 20, 2017

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

Forum|alt.badge.img
  • Author
  • 4 replies
  • September 20, 2017

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!

 

 

 


david_r
Celebrity
  • 8394 replies
  • September 20, 2017

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.

Forum|alt.badge.img
  • 6 replies
  • May 10, 2019

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


fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • May 15, 2019

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>])