RelativePositionZ
Appearance
| 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 |
| vec | A vec3 or vec2 table containing x, y, and optionally z components representing the base position to offset. | |
| bearing | Direction in degrees from north, used to determine the angle of offset (0° is north, 90° is east, etc.). | |
| distance | Distance in meters to move from the base position along the specified bearing. | |
| OutputOpposite | If 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: | ||