This PR is a complete rewrite of the "PitchDimensions" domain model. It implements the following main features.
It implements piecewise linear transformations in each dimension (see Stats Perform MA3 docs, appendix 7) to reduce the error when transforming between different coordinate systems.
transformer = DatasetTransformer(
from_pitch_dimensions=OptaPitchDimensions(),
to_pitch_dimensions=MetricPitchDimensions(
x_dim=Dimension(0, 105),
y_dim=Dimension(0, 68),
pitch_length=105,
pitch_width=68,
standardized=False,
),
)
transformed_point = transformer.change_point_dimensions(
Point(17, 78.9) # the corner of the penalty area...
)
# ... remains the corner of the penalty area
assert transformed_point == Point(16.5, 54.16)
It makes it possible to compute distances between two points without having to transform the entire dataset to a metric coordinate system.
pitch = OptaPitchDimensions(pitch_length=105, pitch_width=68)
distance = pitch.distance_between(Point(0, 50), Point(11.5, 50))
assert distance == 11 # the distance from the goal line to penalty spot should be 11m
Fixes #293
Allows creating pitch dimensions with unknown boundaries. This will allow solving #299 .
BREAKING CHANGES:
This changes the interface of the PitchDimensions class.
This PR is a complete rewrite of the "PitchDimensions" domain model. It implements the following main features.
BREAKING CHANGES:
This changes the interface of the
PitchDimensions
class.