Exemplo n.º 1
0
def signed_angle_between(from_v: Vec2, to_v: Vec2, return_neg: bool = False):
    """
    考虑符号的矢量夹角

    Args:
        from_v: 起始矢量
        to_v: 终止矢量
        returnNegative: 是否返回负值,默认FALSE

    Returns:
        float: 返回夹角弧度值,逆时针为正, 值域[0,2pi]

    """
    res = arctan2(to_v.normalize().y,
                  to_v.normalize().x) - arctan2(from_v.normalize().y,
                                                from_v.normalize().x)
    if return_neg:
        return res
    else:
        if res < 0:
            return 2 * pi + res
        else:
            return res
Exemplo n.º 2
0
    def _append(self, point: Vec2, normal: Vec2, width: float) -> None:
        """
        Add a curve trace station (like a vertex) at location `point`.

        Args:
            point: 2D curve location (vertex), z-axis of 3D vertices is ignored.
            normal: curve normal
            width:  width of station

        """
        if _NULLVEC2.isclose(normal):
            normal = _NULLVEC2
        else:
            normal = normal.normalize(width / 2)
        self._stations.append(CurveStation(point + normal, point - normal))