ckfinite
Posts: 377
Joined: 7/20/2013 Status: offline
|
Okay, at home now. To use (most) of my code, you'll need my math library, just paste it into a lua script that runs on startup. Then, here's the function I use to generate a circle with some random error (so that the target isn't always centered):
local function circle_around(side, point, error, radius, number, naming)
local center = (Quaternion.fromEuler(rng()*error,0,0)*Quaternion.fromEuler(0,0,rng() * 2 * math.pi)) * Quaternion.new(point)
-- debug, real center ScenEdit_AddReferencePoint(point ^ {side=side, name = naming(0)})
local angle = Quaternion.fromEuler(radius,0,0)
local rps = {}
for i=1,number do
rp = ScenEdit_AddReferencePoint((angle * center):toPoint() ^ {side=side, name = naming(i)})
angle = angle * Quaternion.fromEuler(0,0,2*math.pi/number)
table.insert(rps, rp.guid)
end
return rps
end
side is the side you want to make the RPs on, point is a new Point object (make it with Point.new([getunit call])) that represents the point that is the "real" location of the target, error is the maximum distance from the actual center you want to draw the circle, radius is the radius of the circle of RPs, number is the number of RPs to make (if you want to make a square, set this to 4), and naming is a function that given the number of the RP around the circle (from north clockwise), provides the name of the RP (e.g. function (number) return "RP-"..number end)
|