Skip to content

Latest commit

 

History

History
353 lines (342 loc) · 44 KB

Spatial.md

File metadata and controls

353 lines (342 loc) · 44 KB

Spatial

Symbols: 50.6% of Apple's iOS API (652 of 1289, exact) · Rows: 11: 8 ✅ 3 ❌ · iOS: 16.0+

Area: Imaging, photos & ML · Apple: Spatial · Issues: area:ml

How isim implements it

  • Adapted: Spatial's double-precision geometry as pure Swift over simd (isim/swift/overlays/Spatial/): the same math as Apple's, with these conventions where Apple's documentation leaves them open:
    • matrices are column-major on column vectors, so a * b applies b first; rotating, scaling, shearing, flipping or translating a transform (rotated(by:), scaledBy(x:y:z:), …) applies that change after it;
    • Euler angles are extrinsic: .xyz (pitchYawRoll) turns about x, then y, then z; .zxy about z, x, then y;
    • looking along a direction (Rotation3D(forward:up:), Pose3D(position:target:up:)) turns +z toward it;
    • perspective projections are right-handed (the camera looks down -z) with depth 0...1 (1...0 with reverseZ);
    • a box that is rotated, sheared or transformed becomes the axis-aligned box around its transformed corners.
  • C and Objective-C: <Spatial/Spatial.h> (Spatial.framework) is header-only like Apple's: the SP… types are unions and structs over the simd types, and the functions are static inline and overloadable, so there is nothing to link. They follow the Swift overlay's conventions above; the declarations are hidden from Swift, which uses the overlay. The header is generated by isim/tools/spatial-headers.py (the …Float functions it keeps are listed in isim/data/spatial-float-names.txt).
  • Angle2D, Rotation3D and RotationAxis3D first came for Charts' 3D charts; Rotation3D now stores a quaternion and keeps its angle / axis accessors.

API

API / feature Status iOS Notes
Angle2D (degrees / radians, normalized, the inverse trigonometric constructors, arithmetic), sin / cos / tan / sinh / cosh / tanh of an angle ✅ ≤17 adapted. Tested (SpatialTest: test_spatial)
Point3D, Vector3D (dot, cross, projected, reflected, lerp, smoothstep, forward / right / up), Size3D (Volumetric), RotationAxis3D, SphericalCoordinates3D (iOS 18) ✅ ≤17 adapted: transforms apply to points whole (projective ones divide by w) and to vectors and sizes by their linear part. Tested (SpatialTest)
Rotation3D (a quaternion: init(angle:axis:), init(quaternion:), init(eulerAngles:), init(forward:up:), init(position:target:up:), angle, axis, vector, inverse, *, slerp(from:to:t:along:), spline(…), swingTwist(twistAxis:), eulerAngles(order:), isApproximatelyEqual(to:tolerance:), Codable), EulerAngles, EulerAngles.Order (__SPEulerAngleOrder) ✅ ≤17 adapted (extrinsic Euler angles; SlerpPath.automatic takes the shorter arc). Tested (SpatialTest)
Rect3D (init(points:), min / max / center / minX …, cornerPoints, standardized, integral, contains, union, intersection, intersects, distance(to:), inset(by:)), Ray3D (intersects(_:) a box, intersects(sphereOrigin:sphereRadius:)) ✅ ≤17 adapted: rays hit only ahead of their origin; transformed boxes are the bounding boxes of their corners. Tested (SpatialTest)
AffineTransform3D (scale / rotation / translation / shear initializers, 4x4 conversions, init(truncating:), scale, rotation, translation, inverse, isUniform(overDimensions:), changeBasis(from:to:), flipped(along:)), ProjectiveTransform3D (perspective initializers with reverseZ, the frustum tangents, isAffine, is3DProjection(), scaleComponent) ✅ ≤17 adapted: rotation is nil when the transform shears, scale negates x for a reflection. Tested (SpatialTest)
Pose3D, ScaledPose3D (iOS 18): look-at initializers, conversion from transforms (failing when they scale or shear), inverse, * / concatenating(_:), flipped(along:), matrix ✅ ≤17 adapted: a * b and a.concatenating(b) apply b first. Tested (SpatialTest)
Primitive3D, Rotatable3D, Scalable3D, Shearable3D, Translatable3D, Volumetric (with their mutating forms), Axis3D, Dimension3DSet, AxisWithFactors ✅ ≤17 adapted. Tested (SpatialTest)
The single-precision types (Point3DFloat, Rotation3DFloat, …), the *Protocol protocols, SpatialTypeProtocol, CoordinateSpace3D and the world reference space; columns, init(simd_packed_double4) and the iOS 26 Float conversions ❌ 26.0 not implemented: iOS 26's generic layer over the same math
applying(_:) a projective transform to Rotation3D and Pose3D ❌ 27.0 not implemented
init(_:) of RealityKit's Transform and BoundingBox ❌ 18.0 not implemented: RealityKit's types are not Spatial's
The C API: the SP…3D types and their …Float forms (iOS 26), the constants (SP…Zero, …Identity, …Invalid, …) and the SP… inline functions (making, getting, comparing, rotating, scaling, shearing, translating, applying and unapplying transforms and poses, SPRotation3DSlerp / Spline, look-at, Euler angles, boxes, rays, spherical coordinates, conversions between precisions) ✅ ≤17 adapted: header-only <Spatial/Spatial.h> over <simd/simd.h>, generated by isim/tools/spatial-headers.py, the same math as the Swift overlay; every name Apple documents (606). Tested (SpatialCTest against SpatialSwiftTest: test_spatial_c_matches_swift)

Not yet in isim

637 symbols Apple documents for iOS that isim does not have (exact; Apple snapshot 2026-10-14). Each links to Apple's documentation.

List