Page 1 of 1

SetReferencePoint + Bearing/Distance

Posted: Tue Sep 05, 2023 7:41 pm
by Parel803
Good evening,

I added a RP with:

Code: Select all

local u = ScenEdit_GetUnit ({name='CVN 78 Gerald R. Ford', guid='KO61QJ-0HMTE5ENVLTKH'})
ScenEdit_AddReferencePoint({side = 'Nessik', name = 'Z5', relativeto = u.guid, bearingtype=0, bearing=180, distance=10})
Works nicely.
To Set with:

Code: Select all

local u = ScenEdit_GetUnit ({name='CVN 78 Gerald R. Ford', guid='KO61QJ-0HMTE5ENVLTKH'})
ScenEdit_SetReferencePoint({side = 'Nessik', name = 'Z1', relativeto = u.guid, bearingtype=0, bearing=180, distance=10})
Did not work. Made a mistake somewere or is it not possible.

I now used the B/D to Lat/Long I found on the forum (with input box)

Code: Select all

local function GetNumberFromUser(displaytext, minnum, maxnum, errornum)
    local retval = ScenEdit_InputBox(displaytext)
    if retval ~= nil and retval ~= "" then
        retval = tonumber(retval)
        if retval == nil then
            return errornum
        end
    else
        return errornum
    end
    if retval >= minnum and retval <= maxnum then
        return retval
    end
    return errornum
end

-- Create Reference Points Function
local function SetRpsScreen()
    local zz = ScenEdit_GetUnit({name='A 834 Den Helder', guid='KO61QJ-0HMTE5ENVLTR9'})

    local leftBearing = GetNumberFromUser('Enter left bearing (1-360):', 1, 360, 0)
    local rightBearing = GetNumberFromUser('Enter right bearing (1-360):', 1, 360, 0)
    local minDistance = GetNumberFromUser('Enter minimum distance:', 0, 100, 0)
    local maxDistance = GetNumberFromUser('Enter maximum distance:', minDistance, 100, 0)

Code: Select all

    local pt1 = World_GetPointFromBearing({ LATITUDE = zz.latitude, LONGITUDE = zz.longitude, BEARING = leftBearing, DISTANCE = minDistance })
    local pt2 = World_GetPointFromBearing({ LATITUDE = zz.latitude, LONGITUDE = zz.longitude, BEARING = leftBearing, DISTANCE = maxDistance })
    local pt3 = World_GetPointFromBearing({ LATITUDE = zz.latitude, LONGITUDE = zz.longitude, BEARING = rightBearing, DISTANCE = maxDistance })
    local pt4 = World_GetPointFromBearing({ LATITUDE = zz.latitude, LONGITUDE = zz.longitude, BEARING = rightBearing, DISTANCE = minDistance })

    ScenEdit_SetReferencePoint({ side = "Nessik", name = "Z1", lat = pt1.latitude, long = pt1.longitude, relativeto=zz.guid, bearingtype=0 })
    ScenEdit_SetReferencePoint({ side = "Nessik", name = "Z2", lat = pt2.latitude, long = pt2.longitude, relativeto=zz.guid, bearingtype=0 })
    ScenEdit_SetReferencePoint({ side = "Nessik", name = "Z3", lat = pt3.latitude, long = pt3.longitude, relativeto=zz.guid, bearingtype=0 })
    ScenEdit_SetReferencePoint({ side = "Nessik", name = "Z4", lat = pt4.latitude, long = pt4.longitude, relativeto=zz.guid, bearingtype=0 })
end

SetRpsScreen()
Regards GJ

Re: SetReferencePoint + Bearing/Distance

Posted: Wed Sep 06, 2023 5:45 am
by blu3s
If you want to change the name of the RP via SetReferencePoint you need to provide both, name and newname


Untitled.png
Untitled.png (25.16 KiB) Viewed 918 times

If you are adding RP you should use in your function AddReferencePoint and not SetReferencePoint, if you are changing RP coordinates SetReferencePoint works fine

Regards

Re: SetReferencePoint + Bearing/Distance

Posted: Wed Sep 06, 2023 7:23 am
by Parel803
Blu3s,

Thank you for your time and answer.
I was wondering if you could you SetRP for a relative RP by giving the line a bearing and distance, just to change it's position.

regards GJ

Re: SetReferencePoint + Bearing/Distance

Posted: Mon Sep 11, 2023 1:25 pm
by blu3s
You can calculate the new position with the function

https://commandlua.github.io/assets/Fun ... earing.htm

I dont' thnkt that SetRP allows you to enter a bearing and a distance unless you are referring to a point relative to a unit.

Re: SetReferencePoint + Bearing/Distance

Posted: Mon Sep 11, 2023 2:08 pm
by Parel803
Blu3s,

Thank you, understood.

regards GJ