示例#1
0
 def __init__(
     self,
     polylines: Optional[Iterable[Iterable[float]]] = None,
     *,
     category: Optional[str] = None,
     attributes: Optional[Dict[str, Any]] = None,
     instance: Optional[str] = None,
 ):
     MultiPolyline2D.__init__(self, polylines)  # type: ignore[arg-type]
     _LabelBase.__init__(self, category, attributes, instance)
 def test_init(self):
     assert MultiPolyline2D() == MultiPolyline2D([])
     assert MultiPolyline2D(_MULTI_POLYLINE_SEQUENCE) == MultiPolyline2D([
         [Vector2D(1, 1),
          Vector2D(2, 2),
          Vector2D(4, 4),
          Vector2D(5, 5)],
         [Vector2D(2, 1), Vector2D(4, 3),
          Vector2D(6, 5)],
     ])
 def test_loads(self):
     assert MultiPolyline2D.loads(
         _MULTI_POLYLINE_CONTENT) == _MULTI_POLYLINE
#
# Copyright 2021 Graviti. Licensed under MIT License.
#

from math import isclose

from tensorbay.geometry import Box2D, MultiPolyline2D, Polyline2D, Vector2D

_POLYLINE_SEQUENCE_1 = [[1, 1], [2, 2], [4, 4], [5, 5]]
_POLYLINE_SEQUENCE_2 = [[2, 1], [4, 3], [6, 5]]

_POLYLINE_1 = Polyline2D(_POLYLINE_SEQUENCE_1)
_POLYLINE_2 = Polyline2D(_POLYLINE_SEQUENCE_2)

_MULTI_POLYLINE_SEQUENCE = [_POLYLINE_SEQUENCE_1, _POLYLINE_SEQUENCE_2]
_MULTI_POLYLINE = MultiPolyline2D([_POLYLINE_SEQUENCE_1, _POLYLINE_SEQUENCE_2])

_POLYLINE_INFO_1 = (
    {
        "index": 0,
        "point": Vector2D(1, 1),
        "vector": Vector2D(1, 1),
        "time": 0.25,
        "last_time": 0,
    },
    {
        "index": 1,
        "point": Vector2D(2, 2),
        "vector": Vector2D(2, 2),
        "time": 0.75,
        "last_time": 0.25,