// SPDX-License-Identifier: MIT
// Copyright (c) 2026 Incoprea
// Convert world size into screen pixels
// Not compiled or tested in-world
// Setup: Use a spare owned prim. Set positive object height, depth, viewport pixel height and vertical FOV. Touch for private calculations.
// Stop / restore: Disable/remove. No camera or object settings are changed.
// Notes: Assumes a flat front-facing object centered at one depth; complex meshes require projection of their bounds.
// License: see LICENSE in this distribution.
// Original Incoprea. MIT. Transform planning only.
float OBJECT_HEIGHT=2.0;
float DEPTH=10.0;
float VIEWPORT_HEIGHT=1080.0;
float FOV=60.0;
default
{
    touch_start(integer detectedCount)
    {
        if(llDetectedKey(0)!=llGetOwner())return;
        if(OBJECT_HEIGHT<=0.0||DEPTH<=0.0||VIEWPORT_HEIGHT<=0.0||FOV<=1.0||FOV>=170.0)
        {
            llOwnerSay("Invalid inputs.");
            return;
        }
        float pixels=OBJECT_HEIGHT*VIEWPORT_HEIGHT/(2.0*DEPTH*llTan(FOV*DEG_TO_RAD*0.5));
        llOwnerSay("Projected height pixels="+(string)pixels);
    }
}
