Skip to content
  1. API
  2. geometry

geometry ​

Ogma static toolbox for geometry purposes

geometry.computeCentroid(points) ​

Returns the average of the specified points.

Arguments

Returns

geometry.distance(x1, y1, x2, y2) ​

Compute the distance between two points (x1, y1) and (x2, y2).

Arguments

  • x1 number
  • y1 number
  • x2 number
  • y2 number

Returns

  • number Distance between the two points.

geometry.getNormalOnEdge(edge, t) ​

Returns the normal vector of the edge at t. Returns the normal at the source of the edge for t = 0 and at the target for t = 1

Arguments

  • edge Edge An edge
  • t number The interpolation value bounded in [0;1].

Returns

  • object {x,y} The normal to the edge at t

geometry.getPointOnEdge(edge, t) ​

Returns the point of the edge at t. Returns the source of the edge for t = 0 and at the target for t = 1

Arguments

  • edge Edge An edge
  • t number The interpolation value bounded in [0;1].

Returns

  • object {x,y} The position on the edge at t

geometry.getQuadraticCurveControlPoint(x1, y1, x2, y2, curvature, dest?) ​

Returns the control point used to draw a curved edge.

Arguments

  • x1 number X position of the source
  • y1 number Y position of the source
  • x2 number X position of the target
  • y2 number Y position of the target
  • curvature number The curvature factor of the edge
  • dest? Point A Point to write in the result

Returns

  • Point The control point used to draw a curved edge.

geometry.getTangentOnEdge(edge, t) ​

Returns the tangent vector of the edge at t. Returns the tangent at the source of the edge for t = 0 and at the target for t = 1

Arguments

  • edge Edge An edge
  • t number The interpolation value bounded in [0;1].

Returns

  • object {x,y} The tangent to the edge at t