Jump to content

RelativePositionZ

From CMM Wiki
Revision as of 10:12, 11 November 2025 by Ozdeadmeat (talk | contribs) (RelativePositionZ – created via PowerShell script (2025-11-11T21:12:36Z))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Return to CMM Command Reference
Environment: Mission Scripting
Function: RelativePositionZ
Function Description: Calculates a new 3D position by offsetting a given vector using a bearing and distance, with optional output format control. If the input is a vec3 and OutputOpposite is false, it returns a vec3 with adjusted x and z coordinates and y derived from terrain height. If OutputOpposite is true, it returns a vec2 or vec3 based on input type, adjusting accordingly and fetching terrain height when needed.
File Location: cmm.positionFunctions.lua
Syntax: CMM.RelativePositionZ( table vec , number bearing , number distance , boolean OutputOpposite )
Return Value: table
Parameters: Name Description
vecA vec3 or vec2 table containing x, y, and optionally z components representing the base position to offset.
bearingDirection in degrees from north, used to determine the angle of offset (0° is north, 90° is east, etc.).
distanceDistance in meters to move from the base position along the specified bearing.
OutputOppositeIf true, returns a vec2 when input is a vec3 or a vec3 when input is a vec2; if false, returns a vec3 with y derived from terrain height when applicable (defaults to false).
Example: CMM.RelativePositionZ({x=100, y=50, z=10}, 45, 100, false)
Example Description: Returns a vec3 with adjusted x and z coordinates and y derived from terrain height at the new position, offset 100 meters at a 45-degree bearing from the origin.
Related Functions:
Notes: