|
1 | 1 | """Internal data class for spiral drawing data.""" |
2 | 2 |
|
| 3 | +import dataclasses |
3 | 4 | import datetime |
4 | 5 | import typing |
5 | 6 |
|
@@ -116,3 +117,82 @@ def get_extractors( |
116 | 117 | spiral, reference_spiral |
117 | 118 | ), |
118 | 119 | } |
| 120 | + |
| 121 | + |
| 122 | +@dataclasses.dataclass |
| 123 | +class LineSegment: |
| 124 | + """Represents a line drawn between two circles. |
| 125 | +
|
| 126 | + Attributes: |
| 127 | + start_label: Label of the starting circle. |
| 128 | + end_label: Label of the ending circle. |
| 129 | + points: DataFrame containing the points in the line segment. |
| 130 | + is_error: Whether the line segment is an error (missed target). |
| 131 | + line_number: The line number of the segment. |
| 132 | +
|
| 133 | + Calculated features: |
| 134 | + ink_time: Time spent drawing the line segment. |
| 135 | + think_time: Time spent thinking before drawing the line segment. |
| 136 | + think_circle_label: Label of the circle associated with think time. |
| 137 | + distance: Total distance drawn outside circles. |
| 138 | + mean_speed: Mean speed of drawing the line segment. |
| 139 | + speed_variance: Variance of speed during the line segment. |
| 140 | + path_optimality: Ratio of actual path length to optimal path length. |
| 141 | + smoothness: Smoothness of the line segment based on curvature changes. |
| 142 | + hesitation_count: Number of hesitations during the line segment. |
| 143 | + hesitation_duration: Total duration of hesitations during the line segment. |
| 144 | + velocities: List of velocities at each point in the line segment. |
| 145 | + accelerations: List of accelerations at each point in the line segment. |
| 146 | + """ |
| 147 | + |
| 148 | + start_label: str |
| 149 | + end_label: str |
| 150 | + points: pd.DataFrame |
| 151 | + is_error: bool |
| 152 | + line_number: int |
| 153 | + |
| 154 | + ink_time: float = 0.0 |
| 155 | + think_time: float = 0.0 |
| 156 | + think_circle_label: str = "" |
| 157 | + distance: float = 0.0 |
| 158 | + mean_speed: float = 0.0 |
| 159 | + speed_variance: float = 0.0 |
| 160 | + path_optimality: float = 0.0 |
| 161 | + smoothness: float = 0.0 |
| 162 | + hesitation_count: int = 0 |
| 163 | + hesitation_duration: float = 0.0 |
| 164 | + velocities: typing.List[float] = dataclasses.field(default_factory=list) |
| 165 | + accelerations: typing.List[float] = dataclasses.field(default_factory=list) |
| 166 | + |
| 167 | + |
| 168 | +@dataclasses.dataclass |
| 169 | +class CircleTarget: |
| 170 | + """Represents a target circle in the drawing task. |
| 171 | +
|
| 172 | + Attributes: |
| 173 | + order: The order of the circle in the sequence. |
| 174 | + label: The label of the circle. |
| 175 | + center_x: The x-coordinate of the circle's center. |
| 176 | + center_y: The y-coordinate of the circle's center. |
| 177 | + radius: The radius of the circle. |
| 178 | + """ |
| 179 | + |
| 180 | + order: int |
| 181 | + label: str |
| 182 | + center_x: float |
| 183 | + center_y: float |
| 184 | + radius: float |
| 185 | + |
| 186 | + def contains_point(self, x: float, y: float, tolerance: float = 1.5) -> bool: |
| 187 | + """Check if a point is within the circle (with tolerance multiplier). |
| 188 | +
|
| 189 | + Args: |
| 190 | + x: X coordinate of the point. |
| 191 | + y: Y coordinate of the point. |
| 192 | + tolerance: Multiplier for the radius to define tolerance boundary. |
| 193 | +
|
| 194 | + Returns: |
| 195 | + True if the point is within the circle (with tolerance), False otherwise. |
| 196 | + """ |
| 197 | + distance = np.sqrt((x - self.center_x) ** 2 + (y - self.center_y) ** 2) |
| 198 | + return distance <= (self.radius * tolerance) |
0 commit comments