standard library package SpatialItems { doc /* * This package models physical items that have a spatial extent and act as a spatial frame of reference * for obtaining position and displacement vectors of points within them. */ private import Objects::Point; private import SpatialFrames::SpatialFrame; private import Quantities::VectorQuantityValue; private import MeasurementReferences::ThreeDCoordinateFrame; private import MeasurementReferences::nullTransformation; private import Time::Clock; private import Time::TimeInstantValue; private import ScalarValues::Natural; private import ISQ::universalCartesianSpatial3dCoordinateFrame; private import ISQ::Position3dVector; private import ISQ::Displacement3dVector; private import VectorFunctions::isZeroVector; private import SequenceFunctions::isEmpty; private import ControlFunctions::forAll; item def SpatialItem :> SpatialFrame { doc /* * A SpatialItem is an Item with a three-dimensional spatial extent that also acts as a SpatialFrame of reference. */ ref item :>> localClock : Clock[1] default Time::universalClock { doc /* * A local Clock to be used as the corresponding time reference within this SpatialItem. * By default this is the singleton universalClock. */ } attribute coordinateFrame : ThreeDCoordinateFrame[1] default universalCartesianSpatial3dCoordinateFrame { doc /* * The three-dimensional CoordinateFrame to be used as the measurement reference for position * and displacement vector values relative to this SpatialItem. * By default this is the singleton universalCartesianSpatial3dCoordinateFrame. */ } item originPoint : Point[1] :> spaceShots { doc /* * The Point at the origin of the coordinateFrame of this SpatialItem. */ } assert constraint originPointConstraint { doc /* * The CurrentPositionOf the originPoint must always be a zero vector. */ isZeroVector(CurrentPositionOf(originPoint, that)) } item componentItems : SpatialItem[1..*] :> subitems { doc /* * A SpatialItem with componentItems is entirely made up of those items (the SpatialItem occurs only * as a collection of its componentItems). By default they have the same localClock and equivalent * coordinate frame as the SpatialItem they make up. A SpatialItem without componentItems occurs * on its own, separately from its subitems. */ item :>> localClock default (that as SpatialItem).localClock; attribute :>> coordinateFrame { attribute :>> mRefs default (that.that as SpatialItem).coordinateFrame.mRefs; attribute :>> transformation[1] default nullTransformation { attribute :>> source default (that.that.that as SpatialItem).coordinateFrame; } } } private attribute cunionNum: Natural [1] = if isEmpty(componentItems) ? 0 else 1; private attribute componentUnion[cunionNum] :> unionsOf { doc /* * A SpatialItem with componentItems is is a spatial union of them. */ item :>> elements : SpatialItem [1..*] = componentItems; } } calc def PositionOf :> SpatialFrames::PositionOf { doc /* * The PositionOf a Point relative to a SpatialItem, at a specific TimeInstantValue relative to a given Clock, * is a positionVector that is a VectorQuantityValue in the coordinateFrame of the SpatialItem. * The default Clock is the localClock of the SpatialItem. */ in point : Point[1]; in timeInstant : TimeInstantValue[1]; in enclosingItem :>> 'frame' : SpatialItem[1]; in clock : Clock[1] default enclosingItem.localClock; return positionVector : Position3dVector[1] { attribute :>> mRef = enclosingItem.coordinateFrame; } } calc def CurrentPositionOf :> SpatialFrames::CurrentPositionOf { doc /* * The CurrentPositionOf a Point relative to a SpatialItem and a Clock is the PositionOf * the Point relative to the SpatialItem at the currentTime of the Clock. */ in point : Point[1]; in enclosingItem :>> 'frame' : SpatialItem[1]; in clock : Clock[1] default enclosingItem.localClock; return positionVector : Position3dVector[1] { attribute :>> mRef = enclosingItem.coordinateFrame; } } calc def DisplacementOf :> SpatialFrames::DisplacementOf { doc /* * The DisplacementOf two Points relative to a SpatialItem, at a specific TimeInstantValue relative to a * given Clock, is the displacementVector computed as the difference between the PositionOf the * first Point and PositionOf the second Point, relative to that SpatialItem, at that timeInstant. */ in point1 : Point[1]; in point2 : Point[1]; in timeInstant : TimeInstantValue[1]; in spatialItem :>> 'frame' : SpatialItem[1]; in clock : Clock[1] default spatialItem.localClock; return displacementVector : Displacement3dVector[1] { attribute :>> mRef = spatialItem.coordinateFrame; } } calc def CurrentDisplacementOf :> SpatialFrames::CurrentDisplacementOf { doc /* * The CurrentDisplacementOf two Points relative to a SpatialItem and a Clock is the DisplacementOf * the Points relative to the SpatialItem, at the currentTime of the Clock. */ in point1 : Point[1]; in point2 : Point[1]; in spatialItem :>> 'frame' : SpatialItem[1]; in clock : Clock[1] default spatialItem.localClock; return displacementVector : Displacement3dVector[1] { attribute :>> mRef = spatialItem.coordinateFrame; } } }