RosettaCodeData/Task/Classes/Rhovas/classes-2.rhovas
2023-12-16 21:33:55 -08:00

10 lines
276 B
Text

class UnitVector {
val x: Decimal;
val y: Decimal;
init(direction: Vector) {
require direction.x != 0.0 || direction.y != 0.0;
val magnitude = direction.magnitude();
this { x: direction.x / magnitude, y: direction.y / magnitude };
}
}