VE Lua Documentation

Press F to search!

monotonicSteffen

Definition


-- @/lua/common/mathlib.lua:1304

-- 2d, monotonic
function monotonicSteffen(y0, y1, y2, y3, x0, x1, x2, x3, x)
  local x1x0, x2x1, x3x2 = x1-x0, x2-x1, x3-x2
  local delta0, delta1, delta2 = (y1-y0) / (x1x0 + 1e-30), (y2-y1) / (x2x1 + 1e-30), (y3-y2) / (x3x2 + 1e-30)
  local m1 = (sign(delta0)+sign(delta1)) * min(abs(delta0),abs(delta1), 0.5*abs((x2x1*delta0 + x1x0*delta1) / (x2-x0 + 1e-30)))
  local m2 = (sign(delta1)+sign(delta2)) * min(abs(delta1),abs(delta2), 0.5*abs((x3x2*delta1 + x2x1*delta2) / (x3-x1 + 1e-30)))
  local xx1 = x - x1
  local xrel = xx1 / max(x2x1, 1e-30)
  return y1 + xx1*(m1 + xrel*(delta1 - m1 + (xrel - 1)*(m1 + m2 - 2*delta1)))
end

Callers

@/lua/ge/extensions/editor/camPathEditor.lua
  return clamp(
    (monotonicSteffen(0, d12, d12 + d23, d12 + d23 + d34, 0, t1, t1 + t2, t1 + t2 + t3, t1 + t) - d12) / d23,
    0,
      local rot = catmullRomCentripetal(r1, r2, r3, r4, calculateTnorm(sqrt(r1:distance(r2)), sqrt(r2:distance(r3)), sqrt(r3:distance(r4)), t1, t2, t3, camTLocal)):normalized()
      local fov = monotonicSteffen(markers[n1].fov or 60, markers[n2].fov or 60, markers[n3].fov or 60, markers[n4].fov or 60, 0, t1, t1 + t2, t1 + t2 + t3, t1 + camTLocal)
@/lua/ge/extensions/editor/scriptAIEditor.lua
local function calculateTnorm(d12, d23, d34, t1, t2, t3, t)
  return clamp((monotonicSteffen(0, d12, d12 + d23, d12 + d23 + d34, 0, t1, t1 + t2, t1 + t2 + t3, t1 + t) - d12) / d23, 0, 1)
end
@/lua/ge/extensions/editor/toolUtilities/geom.lua
      catmullRomCentripetalFast(p0, p1, p2, p3, t, 0.5, pts[ctr])
      pts[ctr].z = monotonicSteffen(z0, z1, z2, z3, 0, 1, 2, 3, t + 1)
      ctr = ctr + 1
      local tPlus1 = t + 1
      pts[ctr].z = monotonicSteffen(z0, z1, z2, z3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for Z, to stop overshooting under the surface.
      wds[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the width interpolation.
      pts[ctr].z = monotonicSteffen(z0, z1, z2, z3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for Z, to stop overshooting under the surface.
      wds[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the width interpolation.
      ctr = ctr + 1
      local tPlus1 = t + 1
      pts[ctr].z = monotonicSteffen(z0, z1, z2, z3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for Z, to stop overshooting under the surface.
      wds[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the width interpolation.
      pts[ctr].z = monotonicSteffen(z0, z1, z2, z3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for Z, to stop overshooting under the surface.
      wds[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the width interpolation.
      vels[ctr] = monotonicSteffen(v0, v1, v2, v3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the velocity interpolation.
      wds[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the width interpolation.
      vels[ctr] = monotonicSteffen(v0, v1, v2, v3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the velocity interpolation.
      lims[ctr] = monotonicSteffen(l0, l1, l2, l3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the velocity limit interpolation.
      vels[ctr] = monotonicSteffen(v0, v1, v2, v3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the velocity interpolation.
      lims[ctr] = monotonicSteffen(l0, l1, l2, l3, 0, 1, 2, 3, tPlus1) -- Use a monotonic spline for the velocity limit interpolation.
      ctr = ctr + 1
      catmullRomCentripetalFast(n0, n1, n2, n3, t, 0.5, normals[ctr])
      divWidths[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, t + 1)
      ctr = ctr + 1
      catmullRomCentripetalFast(n0, n1, n2, n3, t, 0.5, normals[ctr])
      divWidths[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, t + 1)
      ctr = ctr + 1
      catmullRomCentripetalFast(p0, p1, p2, p3, t, 0.5, divPoints[ctr])
      divPoints[ctr].z = monotonicSteffen(z0, z1, z2, z3, 0, 1, 2, 3, tPlus1)
      catmullRomCentripetalFast(n0, n1, n2, n3, t, 0.5, normals[ctr])
      catmullRomCentripetalFast(n0, n1, n2, n3, t, 0.5, normals[ctr])
      divWidths[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, tPlus1)
      ctr = ctr + 1
      catmullRomCentripetalFast(p0, p1, p2, p3, t, 0.5, divPoints[ctr])
      divPoints[ctr].z = monotonicSteffen(z0, z1, z2, z3, 0, 1, 2, 3, tPlus1)

      divWidths[ctr] = monotonicSteffen(w0, w1, w2, w3, 0, 1, 2, 3, tPlus1)
      ctr = ctr + 1
@/lua/ge/extensions/editor/tech/roadArchitect/geometry.lua
      local qPlus1 = q + 1
      rDisc[ctr] = monotonicSteffen(p1.rot[0], p2.rot[0], p3.rot[0], p4.rot[0], 0, 1, 2, 3, qPlus1)
      oDisc[ctr] = monotonicSteffen(p1.offset, p2.offset, p3.offset, p4.offset, 0, 1, 2, 3, qPlus1)
      rDisc[ctr] = monotonicSteffen(p1.rot[0], p2.rot[0], p3.rot[0], p4.rot[0], 0, 1, 2, 3, qPlus1)
      oDisc[ctr] = monotonicSteffen(p1.offset, p2.offset, p3.offset, p4.offset, 0, 1, 2, 3, qPlus1)
      wDisc[ctr], hLDisc[ctr], hRDisc[ctr] = {}, {}, {}
      for k, _ in pairs(p1.widths) do
        wDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.widths[k][0], p2.widths[k][0], p3.widths[k][0], p4.widths[k][0], 0, 1, 2, 3, qPlus1))
        hLDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsL[k][0], p2.heightsL[k][0], p3.heightsL[k][0], p4.heightsL[k][0], 0, 1, 2, 3, qPlus1))
        wDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.widths[k][0], p2.widths[k][0], p3.widths[k][0], p4.widths[k][0], 0, 1, 2, 3, qPlus1))
        hLDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsL[k][0], p2.heightsL[k][0], p3.heightsL[k][0], p4.heightsL[k][0], 0, 1, 2, 3, qPlus1))
        hRDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsR[k][0], p2.heightsR[k][0], p3.heightsR[k][0], p4.heightsR[k][0], 0, 1, 2, 3, qPlus1))
        hLDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsL[k][0], p2.heightsL[k][0], p3.heightsL[k][0], p4.heightsL[k][0], 0, 1, 2, 3, qPlus1))
        hRDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsR[k][0], p2.heightsR[k][0], p3.heightsR[k][0], p4.heightsR[k][0], 0, 1, 2, 3, qPlus1))
      end
      local qPlus1 = q + 1
      pDisc[ctr].z = monotonicSteffen(p1.p.z, p2.p.z, p3.p.z, p4.p.z, 0, 1, 2, 3, qPlus1)
      rDisc[ctr] = monotonicSteffen(p1.rot[0], p2.rot[0], p3.rot[0], p4.rot[0], 0, 1, 2, 3, qPlus1)
      pDisc[ctr].z = monotonicSteffen(p1.p.z, p2.p.z, p3.p.z, p4.p.z, 0, 1, 2, 3, qPlus1)
      rDisc[ctr] = monotonicSteffen(p1.rot[0], p2.rot[0], p3.rot[0], p4.rot[0], 0, 1, 2, 3, qPlus1)
      oDisc[ctr] = monotonicSteffen(p1.offset, p2.offset, p3.offset, p4.offset, 0, 1, 2, 3, qPlus1)
      rDisc[ctr] = monotonicSteffen(p1.rot[0], p2.rot[0], p3.rot[0], p4.rot[0], 0, 1, 2, 3, qPlus1)
      oDisc[ctr] = monotonicSteffen(p1.offset, p2.offset, p3.offset, p4.offset, 0, 1, 2, 3, qPlus1)
      wDisc[ctr], hLDisc[ctr], hRDisc[ctr] = {}, {}, {}
      for k, _ in pairs(p1.widths) do
        wDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.widths[k][0], p2.widths[k][0], p3.widths[k][0], p4.widths[k][0], 0, 1, 2, 3, qPlus1))
        hLDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsL[k][0], p2.heightsL[k][0], p3.heightsL[k][0], p4.heightsL[k][0], 0, 1, 2, 3, qPlus1))
        wDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.widths[k][0], p2.widths[k][0], p3.widths[k][0], p4.widths[k][0], 0, 1, 2, 3, qPlus1))
        hLDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsL[k][0], p2.heightsL[k][0], p3.heightsL[k][0], p4.heightsL[k][0], 0, 1, 2, 3, qPlus1))
        hRDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsR[k][0], p2.heightsR[k][0], p3.heightsR[k][0], p4.heightsR[k][0], 0, 1, 2, 3, qPlus1))
        hLDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsL[k][0], p2.heightsL[k][0], p3.heightsL[k][0], p4.heightsL[k][0], 0, 1, 2, 3, qPlus1))
        hRDisc[ctr][k] = im.FloatPtr(monotonicSteffen(p1.heightsR[k][0], p2.heightsR[k][0], p3.heightsR[k][0], p4.heightsR[k][0], 0, 1, 2, 3, qPlus1))
      end
@/lua/ge/extensions/core/cameraModes/path.lua
local function calculateTnorm(d12, d23, d34, t1, t2, t3, t)
  return clamp((monotonicSteffen(0, d12, d12 + d23, d12 + d23 + d34, 0, t1, t1 + t2, t1 + t2 + t3, t1 + t) - d12) / d23, 0, 1)
end
  local rot = catmullRomCentripetal(r1, r2, r3, r4, calculateTnorm(sqrt(r1:distance(r2)), sqrt(r2:distance(r3)), sqrt(r3:distance(r4)), t1, t2, t3, camTLocal)):normalized()
  local fov = monotonicSteffen(markers[n1].fov or 60, markers[n2].fov or 60, markers[n3].fov or 60, markers[n4].fov or 60, 0, t1, t1 + t2, t1 + t2 + t3, t1 + camTLocal)
  if markers[n1].nearClip then
  if markers[n1].nearClip then
    local nearClip = monotonicSteffen(markers[n1].nearClip or 0.1, markers[n2].nearClip or 0.1, markers[n3].nearClip or 0.1, markers[n4].nearClip or 0.1, 0, t1, t1 + t2, t1 + t2 + t3, t1 + camTLocal)
    data.res.nearClip = nearClip