@name trig_test2
@inputs 
@outputs 
@persist [DeltaTime CurTime] Base:entity Pos:vector Ang Radius Diameter Test:vector Count
@trigger none

interval(60)

if (!Base) {
    CurTime = curtime()
    DeltaTime = curtime() - CurTime
    
    Diameter = 120
    Radius = Diameter/2
    
    Base = holoCreate(1)
    Pos  = Base:pos() + vec(0, 0, Radius)

    holoModel(1, "hq_cylinder")
    holoScaleUnits(1, vec(Diameter, Diameter, 3))
    holoAlpha(1, 50)
    
    Count = 1
    for (I = 1, 9) {
        Count++
        holoCreate(Count, vec(), vec(1)/12)
    }
}

DeltaTime = curtime() - CurTime
CurTime = curtime()

MPH   = 5
Units = fromUnit( "mph", MPH ) #units per sec MPH*17.6

Vel = vec(Units, 0, 0)*DeltaTime
Pos = Pos + Vel

holoPos(1, Pos)


Rev = (Units / (Diameter * pi()))*DeltaTime
Ang = Ang + 360*Rev

holoAng(1, ang(Ang, 0, 90))

local N = 1
for (I = 1, Count) {
    N++
    local Sin = sin(Ang + (360 / Count)*N)*Radius
    local Cos = cos(Ang + (360 / Count)*N)*Radius
    holoPos(N, Pos + vec(Sin, 0, max(0, Cos) - Radius))
}

#local WP = Base:toWorld( Test )
#holoPos(2, WP:setZ( max(WP:z(), Pos:z() ) - Radius ))


#StepH = Radius/5
#holoPos(3, Pos + vec(sin(Ang)*Radius, 10, max(0, cos(Ang)*Radius) - Radius))
#holoPos(3, Pos + vec(sin(Ang+180)*Radius, -30, max(0, cos(Ang+180)*StepH) - Radius))
