PyANGKernel.GKSegment

class GKSegment

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

These points can contain the (x, y, z) coordinates. It can be used to contain a 2d segment as most of the methods for points have a default z value assigned to 0.

PyANGKernel.GKSegment.from
PyANGKernel.GKSegment.to
__init__()

Creates a going with both initial and ending points set at (0, 0)

__init__(from, to)
Parameters:

Creates a segment defining the initial (from) and end (to) points of this segment

angleBetweenSegments(segment)
Parameters:

segmentGKSegment

Return type:

float

It returns the angle between this segment and the segment ‘segment’ in radians between (-GKPI, GKPI). The convention followed is: the angle is positive if from the first segment to the second one the direction is counterclockwise. If the segments are parallel it returns 0.0

distToPoint2D(p[, resPoint=None])
Parameters:
Return type:

float

Returns the minimum distance from any point of the segment to the point p

distToPoint3D(p)
Parameters:

pGKPoint

Return type:

float

Returns the minimum distance from any point of the segment to the point p

expand2D(factor)
Parameters:

factor – float

It enlarges the segment a distance equal to factor*segmentLength in each extreme. That is, when factor is 2 it will be added a part equal to twice the segment’s length in each end of the segment.

expandFromBackOnwards(aIncrement)
Parameters:

aIncrement – float

It enlarges the segment a distance equal to aIncrement from the back position onwards.

getExpandedPointByLength(point, length)
Parameters:
  • pointGKPoint

  • length – float

Return type:

GKPoint

getExpandedPointByLength. Finds the coordinates of the point, which belongs to the line (and is a prolongation of the segment) and the distance between it and the initial point equals to length UnknownCommand point - initial point UnknownCommand length - length between the initial point and the point we want to find UnknownCommand the expanded point

getLength2D()
Return type:

float

It returns the segment’s length taking into account only the x and y coordinates

getLength3D()
Return type:

float

It returns the segment’s length taking into account all 3 coordinates (x, y and z)

getPerpendicularIntersectionPoint(point, segmentC)
Parameters:
Return type:

GKPoint

getPerpendicularIntersectionPoint. Finds intersection point of a perpendicular to the segmentC (going through the point) with an initial segment UnknownCommand point - a point from which a perpendicular goes UnknownCommand segmentC - segment to which we find a perpendicular UnknownCommand the coordinates of intersection

getPointByLength(point, length)
Parameters:
  • pointGKPoint

  • length – float

Return type:

GKPoint

getPointByLength. Finds the coordinates of the point, which belongs to the segment and the distance between it and the initial point equals to length UnknownCommand point - initial point UnknownCommand length - length between the initial point and the point we want to find UnknownCommand the found point

getPointProjection(point)
Parameters:

pointGKPoint

Return type:

GKPoint

getPointProjection. Returns a projection of the point to the line that goes through the segment UnknownCommand point - initial point UnknownCommand - a projection point

intersects2D(segment2[, inter=None[, includeVertexs=true[, epsilon=0.001]]])
Parameters:
  • segment2GKSegment

  • interGKPoint

  • includeVertexs – bool

  • epsilon – float

Return type:

bool

It returns true if this segment intersects with segment2. If inter is provided the intersection point, if any, will be also returned. If includeVertexs is true, if the intersection point is one of the segment’s vertexes then true will also be returned. Epsilon is the error difference allowed to consider two values equal.

isPointAtLeft(p, epsilon)
Parameters:
Return type:

bool

It returns true when the point p is located on then imaginary line that appears expanding the segment and at the left side of the “from” point of the segment. It returns false otherwise. The epsilon is defined to set the accuracy of the point on the line, that is, the distance at which the point can be located outside the line and considered as inside

isPointAtRight(p, epsilon)
Parameters:
Return type:

bool

It returns true when the point p is located on then imaginary line that appears expanding the segment and at the right side of the “to” point of the segment. It returns false otherwise. The epsilon is defined to set the accuracy of the point on the line, that is, the distance at which the point can be located outside the line and considered as inside

isPointAtRightArea(p)
Parameters:

pGKPoint

Return type:

bool

It return true is p is located at the right area of the segment, and false otherwise. If only x and y corrdinates are taken into account, the vectorial product between the vector that goes from ‘from’ to ‘p’ and the vector that goes from ‘from’ to ‘to’ will have the z positive if true is returned

normalizedDistance2D(p)
Parameters:

pGKPoint

Return type:

float

If the point p is in the segment then the value returned is between 0 and 1, 0 when p equals to “from” and 1 when p equals to “to”. If p is in the segment line but outside the segment, it returns a value less than 0 when the nearest point is “from” and a value greater than 1 when the nearest point is “to”.

onSegment2D(p, epsilon[, useVertexs=true])
Parameters:
  • pGKPoint

  • epsilon – float

  • useVertexs – bool

Return type:

bool

This function returns true if the point “p” is on the segment taking into account the coordinates in the 2D space and with a maximum distance ‘epsilon’ to the segment. If useVertexs is true and p is a vertex of the segment it will return true and false otherwise

onSegment3D(p, epsilon)
Parameters:
Return type:

bool

This function returns true if the point “p” is on the segment taking into account the coordinates in the 3D space and with a maximum distance ‘epsilon’ to the segment

parallelDist(side, dist)
Parameters:
Return type:

GKSegment

Finds the parallel segment at distance “dist”, either at the right or at the left side.

pointAtDist(dist)
Parameters:

dist – float

Return type:

GKPoint

It finds the point in the segment located at distance “dist” from the beginning of the segment. Note that the beginning is the point called “from”

pointAtDist2D(dist)
Parameters:

dist – float

Return type:

GKPoint

It finds the point in the segment located at distance “dist” from the beginning of the segment, without taking into account the z coordinate, that is, in 2D. Note that the beginning is the point called “from”

rotate(center, angle)
Parameters:
  • centerGKPoint

  • angle – float

It rotates this segment “angle” radians using “center” as the center point of the rotation

set(p1, p2)
Parameters:

It sets the initial and end points of the segment to p1 and p2 respectively

toRectangle(width)
Parameters:

width – float

Return type:

GKPoints

Converts the segment into a rectangle expanding it width/2.0 in all four rectangle faces

translate(delta)
Parameters:

deltaGKPoint

Applies a translation delta