Skip to content

Commit

Permalink
feat: add RectangularSensor to Viewer (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwa2710 authored Jan 30, 2024
1 parent f30b9b8 commit acecb5c
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions bindings/python/tools/python/ostk/astrodynamics/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class ConicSensor(Sensor):
length: Length


@dataclass
class RectangularSensor(Sensor):
x_half_angle: Angle
y_half_angle: Angle
radius: Length


class Viewer:
def __init__(
self,
Expand Down Expand Up @@ -296,14 +303,24 @@ def _cesium_from_ostk_quaternion(quaternion: Quaternion) -> cesiumpy.Quaternion:
)


def _cesium_from_ostk_sensor(sensor: Sensor) -> cesiumpy.ConicSensor:
if not isinstance(sensor, ConicSensor):
raise NotImplementedError("Only Conic Sensor is supported at the moment.")
def _cesium_from_ostk_sensor(sensor: Sensor) -> cesiumpy.Sensor:
if isinstance(sensor, ConicSensor):
return cesiumpy.ConicSensor(
name=sensor.name,
direction=cesiumpy.Cartesian3(*sensor.direction),
half_angle=float(sensor.half_angle.in_radians()),
length=float(sensor.length.in_meters()),
material=sensor.color or cesiumpy.color.RED,
)

return cesiumpy.ConicSensor(
name=sensor.name,
direction=cesiumpy.Cartesian3(*sensor.direction),
half_angle=float(sensor.half_angle.in_radians()),
length=float(sensor.length.in_meters()),
material=sensor.color or cesiumpy.color.RED,
)
elif isinstance(sensor, RectangularSensor):
return cesiumpy.RectangularSensor(
name=sensor.name,
direction=cesiumpy.Cartesian3(*sensor.direction),
x_half_angle=float(sensor.x_half_angle.in_radians()),
y_half_angle=float(sensor.y_half_angle.in_radians()),
radius=float(sensor.radius.in_meters()),
material=sensor.color or cesiumpy.color.ORANGE,
)

raise NotImplementedError("{sensor.__name__} is not supported yet.")

0 comments on commit acecb5c

Please sign in to comment.