acos
Definition
-- @/=[C]:-1
function acos(...)
Callers
@/lua/vehicle/controller/tech/tyreBarrier.lua
local FLWh, FRWh = wheels.wheelRotators[wheels.wheelRotatorIDs.FL], wheels.wheelRotators[wheels.wheelRotatorIDs.FR]
local frontLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(FLWh.node2, FLWh.node1)) * steeringSign
local frontRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(FRWh.node1, FRWh.node2)) * steeringSign
local frontLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(FLWh.node2, FLWh.node1)) * steeringSign
local frontRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(FRWh.node1, FRWh.node2)) * steeringSign
return frontLeftWheelAngle, frontRightWheelAngle
@/lua/ge/extensions/util/procTrack.lua
local det = (nodes[i-2].n.x * -nodes[i-1].n.x + nodes[i-2].n.y * -nodes[i-1].n.y)
nodes[i-1].angleRad = math.acos(det)
nodes[i-1].angleDeg = (nodes[i-1].angleRad * 180) / math.pi
nodes[i-1].angleDeg = (nodes[i-1].angleRad * 180) / math.pi
nodes[i-1].globAngleDeg = (math.acos(nodes[i-1].n.x ) * 180) / math.pi -- the angle with the x-axis, needed later
-- fix nodes facing -y direction
nodes[i].pass.sameAsBefore = true
nodes[i-1].pass.outAngleRad = ( math.acos((nodes[i-1].radius - nodes[i].radius)/ nodes[i-1].v.length ))
nodes[i].pass.inAngleRad = math.pi - math.acos((nodes[i-1].radius - nodes[i].radius)/ nodes[i-1].v.length )
nodes[i-1].pass.outAngleRad = ( math.acos((nodes[i-1].radius - nodes[i].radius)/ nodes[i-1].v.length ))
nodes[i].pass.inAngleRad = math.pi - math.acos((nodes[i-1].radius - nodes[i].radius)/ nodes[i-1].v.length )
else
nodes[i].pass.sameAsBefore = false
nodes[i-1].pass.outAngleRad = math.acos((nodes[i-1].radius + nodes[i].radius)/ nodes[i-1].v.length )
nodes[i].pass.inAngleRad = math.acos((nodes[i-1].radius + nodes[i].radius)/ nodes[i-1].v.length )
nodes[i-1].pass.outAngleRad = math.acos((nodes[i-1].radius + nodes[i].radius)/ nodes[i-1].v.length )
nodes[i].pass.inAngleRad = math.acos((nodes[i-1].radius + nodes[i].radius)/ nodes[i-1].v.length )
end
--dump(nv)
local angle = (math.acos(nv.x) * 180) / math.pi
if nv.y < 0 then
local angle = (math.acos(inside.x) * 180) / math.pi
if inside.y < 0 then
@/lua/ge/extensions/editor/gen/utils.lua
if (u:normalized()-v:normalized()):length() < 0.00000001 then return 0 end
-- math.acos(u:normalized():dot(v:normalized()))
if math.abs(crs) < 0.0000001 then
return (crs > 0 and 1 or -1)*math.acos(u:dot(v)/u:length()/v:length())
end
end
-- lo('?? vang:'..tostring(u)..':'..tostring(v)..':'..tostring(math.acos(u:dot(v)/u:length()/v:length())))
local cs = u:dot(v)/u:length()/v:length()
--` lo('?? vang:'..tostring(cs)..':'..tostring(cs==-1))
-- if dbg then lo('?? vang:'..tostring(u)..':'..tostring(v)..':'..tostring(cs)..':'..tostring(math.acos(cs))) end
if math.abs(cs+1)<0.0000001 then
return math.acos(cs)
end
@/lua/vehicle/extensions/advancedwheeldebug.lua
local casterSign = -obj:nodeVecCos(wd.steerAxisUp, wd.steerAxisDown, surfaceForward)
wheelData.caster = deg(acos(obj:nodeVecPlanarCos(wd.steerAxisUp, wd.steerAxisDown, surfaceUp, surfaceForward))) * sign(casterSign)
wheelData.sai = deg(acos(obj:nodeVecPlanarCos(wd.steerAxisUp, wd.steerAxisDown, surfaceUp, surfaceRight)))
wheelData.caster = deg(acos(obj:nodeVecPlanarCos(wd.steerAxisUp, wd.steerAxisDown, surfaceUp, surfaceForward))) * sign(casterSign)
wheelData.sai = deg(acos(obj:nodeVecPlanarCos(wd.steerAxisUp, wd.steerAxisDown, surfaceUp, surfaceRight)))
end
--local camberSign = obj:nodeVecCos(wd.node2, wd.node2, vectorForward) --unused
wheelData.camber = (90 - deg(acos(obj:nodeVecPlanarCos(wd.node2, wd.node1, surfaceUp, surfaceRight))))
local toeSign = obj:nodeVecCos(wd.node1, wd.node2, vehForward)
local toeSign = obj:nodeVecCos(wd.node1, wd.node2, vehForward)
wheelData.toe = deg(acos(obj:nodeVecPlanarCos(wd.node1, wd.node2, vehRight, vehForward)))
if wheelData.toe > 90 then
@/lua/ge/extensions/core/cameraModes/orbit.lua
local targetDir = -defaultCamPos
local angleCamTargetCamBottomRear = math.acos(bottomRearDir:cosAngle(targetDir))
@/lua/ge/extensions/editor/gen/top.lua
if d < dmi and ang < 10*small_ang then
-- lo('?? pU_j:'..U.mod(j,#base)..' d:'..d..'/'..tostring(dmi)..' ang:'..tostring(ang)) --..':'..tostring(u)..':'..tostring(v)..':'..tostring(U.vang(u,v))..':'..tostring(u:dot(v)/u:length()/v:length())..':'..tostring(math.acos(u:dot(v)/u:length()/v:length())))
local cmi = {U.mod(i+ishift,#base),U.mod(j,#base)}
@/lua/ge/extensions/editor/masterSpline/autoRoadGen.lua
local dot = prev_dir.x * next_dir.x + prev_dir.y * next_dir.y -- The dot product of the previous and next directions.
local angle = acos(max(-1, min(1, dot))) -- The angle between the previous and next directions.
local radius = dist / (angle + 1e-6) -- The radius of the circle that fits the previous and next directions.
@/lua/ge/extensions/gameplay/drift/drift.lua
driftAngleDiff = math.deg(math.acos(velDir:cosAngle(driftActiveData.lastFrameVelDir))) -- angle in deg
@/ui/lib/ext/spine-canvas.js
cos = 1;
a2 = Math.acos(cos) * bendDir;
a = l1 + l2 * cos;
}
var angle = Math.acos(-a * l1 / (aa - bb));
x = a * Math.cos(angle) + l1;
@/lua/vehicle/controller/playerController.lua
local angleHorizontal = acos(min(max(vectorUp:dot(projectedVertical), -1), 1))
local horizontalAngleSign = sign(normalLeft:dot(vectorUp:cross(projectedVertical)))
local horizontalAngleSign = sign(normalLeft:dot(vectorUp:cross(projectedVertical)))
local angleVertical = acos(min(max(vectorUp:dot(projectedHorizontal), -1), 1))
local verticalAngleSign = sign(normalRight:dot(vectorUp:cross(projectedHorizontal)))
@/gameplay/missionTypes/scatterPickup/customNodes/scatterPrefabSetupNode.lua
if option.align then
local angle = (math.acos(vec3(0,0,1):dot(point.normal))) / math.pi * 180
if angle <= option.align then
@/lua/vehicle/controller/tech/roadsSensor.lua
local alfa = 0.5
headingAngle = alfa*acos(max(-1, min(1, fwdproj:dot(lineSegNormproj)))) + (1-alfa)*headingAngle_prev-- New
if headingAngle < 1.5*math.pi/180 then
@/lua/ge/extensions/editor/toolUtilities/geom.lua
local dot = clamp(abNorm:dot(bcNorm), -1.0, 1.0)
local angle = acos(dot)
local avgLen = 0.5 * (abLen + bcLen)
-- Computes the (small) angle between two unit vectors, in radians.
local function angleBetweenVecsNorm(a, b) return acos(a:dot(b)) end
tmp1:normalize()
return acos(tmp0:dot(tmp1))
end
tmp1:normalize()
return acos(tmp0:dot(tmp1))
end
local dotAB = clamp(a:dot(b), -1, 1)
local angle = acos(dotAB)
tmp0:setCross(a, b)
local dot = max(-1, min(1, fromProj:dot(toProj)))
local angle = acos(dot) -- The unsigned angle.
local sign = (fromProj:cross(toProj)):dot(axis) >= 0 and 1 or -1 -- Determine the sign of the angle.
local dot = clamp(tmp0:dot(tmp1), -1, 1)
local angle = acos(dot)
local avgLen = 0.5 * (len0 + len1)
-- Calculate angle between the two vectors
local unsignedAngle = acos(max(-1, min(1, tmp1:dot(tmpTangent))))
local avgLen = 0.5 * (tmp1:length() + tmpTangent:length())
@/lua/ge/extensions/editor/buildingEditor.lua
U.vang = function(u, v)
return math.acos(u:dot(v)/u:length()/v:length())
end
@/lua/vehicle/controller/drivingDynamics/sensors/vehicleData.lua
M.frontLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontLeftWheel.node2, frontLeftWheel.node1)) * steeringSign
M.frontRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontRightWheel.node1, frontRightWheel.node2)) * steeringSign
M.frontLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontLeftWheel.node2, frontLeftWheel.node1)) * steeringSign
M.frontRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontRightWheel.node1, frontRightWheel.node2)) * steeringSign
M.rearLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(rearLeftWheel.node2, rearLeftWheel.node1))
M.frontRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontRightWheel.node1, frontRightWheel.node2)) * steeringSign
M.rearLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(rearLeftWheel.node2, rearLeftWheel.node1))
M.rearRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(rearRightWheel.node1, rearRightWheel.node2))
M.rearLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(rearLeftWheel.node2, rearLeftWheel.node1))
M.rearRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(rearRightWheel.node1, rearRightWheel.node2))
@/lua/ge/extensions/core/groundMarkerArrows.lua
--wpLog.nodeToNodeAngle = math.acos(dirPrevPoint:cosAngle(dirNextPoint)) * 180/math.pi
--wpLog.wp = path[i].wp
if (path[i].linkCount and path[i].linkCount > 2) and path[i].wp then
local nodeToNodeAngle = math.acos(dirPrevPoint:cosAngle(dirNextPoint)) * 180/math.pi
local dirConnectedNode = (connectedNodePos - path[i].pos); dirConnectedNode:normalize()
local connectedNodeAngle = math.acos(dirPrevPoint:cosAngle(dirConnectedNode)) * 180/math.pi
if nodeToNodeAngle > connectedNodeAngle then
@/lua/ge/extensions/editor/tech/roadArchitect/utilities.lua
local theta = acos(dot) * t
local sin_theta_1_minus_t = sin((1 - t) * theta)
-- Computes the (small) angle between two unit vectors, in radians.
local function angleBetweenVecsNorm(a, b) return acos(a:dot(b)) end
local dot_product = (v1x * v2x) + (v1y * v2y)
local angle = acos(dot_product / (mag_v1 * mag_v2))
local cross_product = (v1x * v2y) - (v1y * v2x)
@/lua/vehicle/controller/esc.lua
wheelAngleFront = acos(obj:nodeVecPlanarCosRightForward(wheelFront.node1, wheelFront.node2))
wheelAngleRear = acos(obj:nodeVecPlanarCosRightForward(wheelRear.node1, wheelRear.node2))
wheelAngleFront = acos(obj:nodeVecPlanarCosRightForward(wheelFront.node1, wheelFront.node2))
wheelAngleRear = acos(obj:nodeVecPlanarCosRightForward(wheelRear.node1, wheelRear.node2))
if wheelAngleFront > 1.5708 then
local dot = velocityVector:dot(directionVector)
local floatAngle = acos(min(max(dot / (directionVector:length() * velocityVector:length()), -1), 1))
@/lua/common/mathlib.lua
if dot > 0.9995 then return self + t*(b-self) end
local th = math.acos(dot)
return math.sin(th * (1-t)) * self + math.sin(th * t) * b
if dot > 0.9995 then return self:nlerp(a, t) end
local theta = math.acos(dot)*t
return (self*math.cos(theta) + (a - self*dot):normalized()*math.sin(theta)):normalized()
local sinhalf = math.sqrt(self.x * self.x + self.y * self.y + self.z * self.z)
local tw = math.acos(clamp(self.w, -1, 1)) * 360 / math.pi
if sinhalf ~= 0 then
@/lua/vehicle/extensions/mqttGrafanaDemo.lua
if wd.steerAxisUp and wd.steerAxisDown then
wheelData.caster = deg(acos(obj:nodeVecPlanarCos(wd.steerAxisUp, wd.steerAxisDown, vectorUp, vectorForward)))
wheelData.sai = deg(acos(obj:nodeVecPlanarCos(wd.steerAxisUp, wd.steerAxisDown, vectorUp, vectorRight)))
wheelData.caster = deg(acos(obj:nodeVecPlanarCos(wd.steerAxisUp, wd.steerAxisDown, vectorUp, vectorForward)))
wheelData.sai = deg(acos(obj:nodeVecPlanarCos(wd.steerAxisUp, wd.steerAxisDown, vectorUp, vectorRight)))
end
--local camberSign = obj:nodeVecCos(wd.node2, wd.node2, vectorForward) --unused
wheelData.camber = (90 - deg(acos(obj:nodeVecPlanarCos(wd.node2, wd.node1, vectorUp, vectorRight))))
local toeSign = obj:nodeVecCos(wd.node1, wd.node2, vectorForward)
local toeSign = obj:nodeVecCos(wd.node1, wd.node2, vectorForward)
wheelData.toe = deg(acos(obj:nodeVecPlanarCos(wd.node1, wd.node2, vectorRight, vectorForward)))
if wheelData.toe > 90 then
@/gameplay/missionTypes/precisionParking/customNodes/parkingPointsNode.lua
local pts = 0
local angle = math.acos(self.pinIn.dotAngle.value)/math.pi * 180
if angle ~= angle then angle = 0 end
@/lua/vehicle/extensions/escMeasurement.lua
local dot = velocityVector:dot(directionVector)
local floatAngle = acos(min(max(dot / (directionVector:length() * velocityVector:length()), -1), 1))
@/lua/ge/extensions/editor/toolUtilities/render.lua
tmpB:normalize()
local angle = acos(tmpA:dot(tmpB)) -- The angle between the two vectors.
local step = -sign2(twistAngle) * angle * numArcSegmentsInv
@/lua/ge/extensions/freeroam/crashCamMode.lua
local inclineDir = hitPoint2 - hitPoint1
local inclineAngle = math.acos(inclineDir:cosAngle(playerVel)) * 180/math.pi
@/lua/ge/extensions/gameplay/rally/notebook/pacenoteGenerator.lua
local angleCos = adotb / (d1l * d2l + 1e-30)
local angleRad = acos(clamp(angleCos, -1, 1))
local angle = deg(angleRad) * 2
@/inspector/External/three.js/three.js
return Math.acos( _Math.clamp( theta, - 1, 1 ) );
this.w = 2 * Math.acos( q.w );
this.z = ( m21 - m12 ) / s;
this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );
theta = Math.acos( _Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
theta = Math.acos( _Math.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
theta /= segments;
this.theta = Math.atan2( vec3.x, vec3.z ); // equator angle around y-up axis
this.phi = Math.acos( _Math.clamp( vec3.y / this.radius, - 1, 1 ) ); // polar angle
radians = Math.acos( dir.y );
@/lua/ge/extensions/tech/sensors.lua
-- Computes the (small) angle between two unit vectors, in radians.
local function angleBetweenVecsNorm(a, b) return math.acos(a:dot(b)) end
@/lua/vehicle/controller/tech/cosimulationCoupling.lua
wOut[wCtr + 5] = frictionTorque -- Friction torque, Nm.
wOut[wCtr + 6] = acos(obj:nodeVecPlanarCosRightForward(wheel.node1, wheel.node2)) * stInSign -- Road wheel angle, rad.
wCtr = wCtr + 7
@/lua/ge/extensions/gameplay/rally/geometry.lua
local angleCos = adotb / (d1l*d2l + 1e-30)
local angleRad = acos(clamp(angleCos, -1, 1))
local angle = deg(angleRad)*2
@/lua/ge/extensions/util/trackBuilder/splineTrack.lua
local cameraAngle = (math.atan2(cameraLook.y, -cameraLook.x) - math.pi / 2)
local cameraUp = math.acos(cameraLook.z) - math.pi / 2
@/lua/ge/extensions/career/modules/delivery/precisionParking.lua
local dotAngle = vehicleDir:dot(targetDir)
local angle = math.acos(math.max(-1, math.min(1, dotAngle))) / math.pi * 180
if angle ~= angle then angle = 0 end -- Handle NaN
@/lua/ge/map.lua
local l1, l2 = v1:length(), v2:length()
return 2 * math.acos(clamp(v1:dot(v2) / (l1 * l2), -1, 1)) / (l1 + l2)
end
@/lua/vehicle/extensions/tech/trailSim.lua
local trailerDirection = trailerVehicle.dirVec:z0():normalized()
--trailerAngle = deg(acos(vehicleDirection:dot(trailerDirection)))
trailerAngle = deg(atan2(vehicleDirection:cross(trailerDirection):dot(vec3(0, 0, 1)), vehicleDirection:dot(trailerDirection)))
local steeringSign = sign(electrics.values.steering or 0)
local frontLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontLeftWheel.node2, frontLeftWheel.node1)) * steeringSign
local frontRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontRightWheel.node1, frontRightWheel.node2)) * steeringSign
local frontLeftWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontLeftWheel.node2, frontLeftWheel.node1)) * steeringSign
local frontRightWheelAngle = acos(obj:nodeVecPlanarCosRightForward(frontRightWheel.node1, frontRightWheel.node2)) * steeringSign
@/lua/ge/extensions/gameplay/rally/snaproad/geoPacenotes.lua
-- local angleCos = adotb / (math.sqrt(asql * bsql) + 1e-30)
-- local angleRad = math.acos(math.max(-1, math.min(1, angleCos)))
-- local angle = math.deg(angleRad) * 2