Esempio n. 1
0
def create_system_by_points(origin, x_axis, xz_plane):
    """
    Coordinate system by three points.
    """
    origin, x_axis, xz_plane = CheckGeom.to_points([origin, x_axis, xz_plane])
    for p in [origin, x_axis, xz_plane]:
        if not CheckGeom.is_point(p):
            return None
    vx = vector_by_points(x_axis, origin)
    vy = vector_by_points(origin, x_axis, xz_plane)
    vz = vx.cross(vy)
    return System(origin, vx, vy, vz)
Esempio n. 2
0
    def point(xyz=(0., 0., 0.)):
        """
        Create a Point.

        :param array_like xyz: Location of point.

        :return: Point at *xyz*.
        :rtype: :class:`.Point`
        """
        if CheckGeom.is_point(xyz):
            return xyz.copy()
        if len(xyz) == 3:
            return Point(xyz)
        return None
Esempio n. 3
0
    def invert(point, geom, ends=True):
        """
        Return the parameters of the nearest orthogonal projection to the
        geometry.

        :param point: Point to project.
        :type point: :class:`.Point`
        :param geom: Curve or surface entity to find parameters.
        :param bool ends: Option to project point to the nearest end point of a
            curve, or to the nearest boundary curve of a surface if no
            orthogonal projection is found.

        :return: Parameter(s) on the geometry of the nearest orthogonal
            projection. For a curve a single float *u* is returned,
            for a surface a tuple (u, v) is returned.
        :rtype: float or tuple

        .. note::
            *None* is returned if no points are found or the method fails. A
            tuple (*None*, *None*) is returned for a surface.
        """
        point = CheckGeom.to_point(point)
        if not CheckGeom.is_point(point):
            if CheckGeom.is_curve_like(geom):
                return None
            return None, None

        if CheckGeom.is_curve_like(geom):
            proj = ProjectPointToCurve(point, geom, ends)
            if not proj.success:
                return None
            return proj.nearest_param
        if CheckGeom.is_surface(geom):
            proj = ProjectPointToSurface(point, geom, ends)
            if not proj.success:
                return None, None
            return proj.nearest_param
        if CheckGeom.is_plane(geom):
            proj = ProjectPointToPlane(point, geom)
            if not proj.success:
                return None, None
            return proj.nearest_param
        return None
Esempio n. 4
0
 def __init__(self, point, surface, ends=True, all_pnts=False):
     super(ProjectPointToSurface, self).__init__()
     point = CheckGeom.to_point(point)
     if CheckGeom.is_point(point) and CheckGeom.is_surface(surface):
         self._perform(point, surface, ends, all_pnts)
Esempio n. 5
0
 def __init__(self, point, curve, ends=True, all_pnts=False):
     super(ProjectPointToCurve, self).__init__()
     point = CheckGeom.to_point(point)
     if CheckGeom.is_point(point) and CheckGeom.is_curve_like(curve):
         self._perform(point, curve, ends, all_pnts)
Esempio n. 6
0
 def __init__(self, point, plane):
     super(ProjectPointToPlane, self).__init__()
     point = CheckGeom.to_point(point)
     if CheckGeom.is_point(point) and CheckGeom.is_plane(plane):
         self._perform(point, plane)