GIANT & MINI / STUDY / LEVEL 5 OF 5

Climbing
the lamp.

On the giant's desk stands an ordinary swing-arm lamp. For the mini its two arms are stairways: up the lower arm to a landing at the elbow, eight feet above the desk, then back the other way up the upper arm to a lookout behind the shade, fourteen feet up. The scene has no collision detection and the mini never lifts a foot. The mini walks flat, as always, and every frame one function answers a question: at this spot, for feet at this height, how high is the ground? The feet then ease toward the answer. On a stair the answer rises a little with every step forward, and that is climbing.

where am I on the lamp?along its plane, and to which side
→
which surfaces are at this spot?base, a stair, the landing, the lookout, the desk
⇒
the highest one within a stepelse the highest one below: a fall

The lamp, from the side

walk with the sliders

What the function weighs

at my spot, for my feet

The two arms are side by side seen from above, one lane each. On the landing you choose: the lower arm's lane takes you down, the upper arm's lane takes you up. In a first version both arms were in the same plane, one above the other, and walking forward from the landing always took the higher one: there was no way down.

The lamp as numbers

desk.js

The lamp leans in one vertical plane. A point of it is written [s, y]: how far along that plane, and how high. The picture of the lamp and this function read the same three points A, B and C.


      

How high is the ground?

desk.js

      

Feet ease toward it

giantMini.js

The same lines serve the lamp, the house floor and the desk. The mini's height lives in origin.y: feet height on the desk is −origin.y ÷ 12. The height is computed again every frame from where the mini is, never added up, so coming back down always ends at exactly desk height.


      
    

What you should be able to explain

  1. Why the feet's height is an input. One spot on the desk can have several surfaces above it. Standing on the desk under an arm, the stair overhead is more than a step away, so the ground is the desk. On the stair at the same spot, the stair is the ground.
  2. Why "highest within a step". A foot steps up onto what is in front of it. Taking the nearest surface instead would keep a mini on the desk for ever, because the desk is always exactly at their feet when they start.
  3. Falling. If nothing is within a step, the mini is in the air, and the answer is the highest surface below. That covers stepping off the side and being put down by the giant with the same rule.
  4. What this is not. It is not collision. The mini can still walk through the lamp's rods. It is a height function for one object, joined to the frame loop at the one place that already chose between the house floor and the desk.

Exercises: ① Climb to the landing, then slide "step sideways" slowly to the other lane. Does your height change on the landing? ② From the lookout, step sideways off it. Where do you land, and which line gave that answer? ③ Use "Stand on the desk under the upper arm": the upper stair is about 10 ft overhead. What would have to change for the function to lift you onto it?