Expanding Circle Refpoints

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
Parel803
Posts: 891
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Expanding Circle Refpoints

Post by Parel803 »

First let me thank all that always willing to help me out in the Lua stuff, I'm no programmer at all, so it's pretty hard.
I learned here to make a cicle with refpoints based on a Lat/Long.
Question 1: is it possible to make this cicle with an expanding radius (based on speed)?
Question 2: is it possible to make the centre of a circle on an existing track?
The reason I'm trying this is that I want a area where a unit might be based on a intelligence message, postion course and speed. Try to make a third (blind) side with the intel information. Hoping it makes some sense.
with regards
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: Expanding Circle Refpoints

Post by Rory Noonan »

Yes, you can simply modify the position of existing reference points--moving them closer to or further from the centrepoint as necessary to contract and expand the circle respectively.

To centre the circle on an existing track, simply use the lat/lon of the existing track as the centrepoint. If you want the circle to move with the track, you can make the reference points relative to the track.
Image
Parel803
Posts: 891
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Expanding Circle Refpoints

Post by Parel803 »

Thank you very much, gonna try tonight.
With regards
Parel803
Posts: 891
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Expanding Circle Refpoints

Post by Parel803 »

I now have some Refpoints around a unit. This from the help in another thread. For a circle, do I make just more refpoints, or is there an easier way to make a circle around a unit. Thanks
with regards
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: Expanding Circle Refpoints

Post by Rory Noonan »

To place a circle of RPs around a unit
local unit = ScenEdit_GetUnit({side='pick a side',name='pick a unit'})
local circle = World_GetCircleFromPoint({latitude = unit.latitude, longitude = unit.longitude, numpoints = 12})

for each,point in ipairs(circle) do
rp = ScenEdit_AddReferencePoint({side='pick a side',name='pick a name '..each, latitude=point.latitude, longitude=point.longitude})
end
To change an existing circle of RPs radius (using the example names from code above)
local newRadius = 25
local unit = ScenEdit_GetUnit({side='pick a side',name='pick a unit'})
local circle = World_GetCircleFromPoint({latitude = unit.latitude, longitude = unit.longitude, numpoints = newRadius})

for each,point in ipairs(circle) do
rp = ScenEdit_GetReferencePoint({side='pick a side', name='pick a name '..each})
ScenEdit_SetReferencePoint({side=rp.side, guid=rp.guid, latitude=point.latitude, longitude=point.longitude})
end

https://commandlua.github.io/#World_GetCircleFromPoint
Image
Parel803
Posts: 891
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Expanding Circle Refpoints

Post by Parel803 »

Thx again for you're time and answer. Much appriciated.
with regards
Post Reply

Return to “Lua Legion”