diff --git a/map_gen/ores/rso/metaball.lua b/map_gen/ores/rso/metaball.lua index 266fe26f..f4048d7b 100644 --- a/map_gen/ores/rso/metaball.lua +++ b/map_gen/ores/rso/metaball.lua @@ -4,6 +4,8 @@ For bruteforce usage, not efficient nor fast Force scales to from inf to 1 at R --]]-- + +local math = require "utils.math" local _M = {} local sqrt = math.sqrt local cos = math.cos @@ -28,7 +30,7 @@ function MetaBall:force(x, y) return (self.radius / force)^self.goo end ---Ellipse +--Ellipse local MetaEllipse = {x=0, y=0, radius=0, angle=0, x_scale=1, y_scale=1, type="MetaEllipse"} MetaEllipse.__index = MetaEllipse _M.MetaEllipse=MetaEllipse @@ -45,7 +47,7 @@ end function MetaEllipse:force(x, y) --Calculate force at point x y - local force = sqrt( (( (x - self.x)*self.cosa + (y - self.y)*self.sina )^2)/(self.x_scale) + + local force = sqrt( (( (x - self.x)*self.cosa + (y - self.y)*self.sina )^2)/(self.x_scale) + (( (y - self.y)*self.cosa - (x - self.x)*self.sina )^2)/(self.y_scale) ) if force == 0 then return zero_value end return (self.radius / force)^self.goo @@ -68,8 +70,8 @@ end function MetaSquare:force(x, y) --Calculate force at point x y - local force = ( abs( (x - self.x)*self.cosa + (y - self.y)*self.sina )/self.x_scale + - abs( (y - self.y)*self.cosa - (x - self.x)*self.sina )/self.y_scale ) + local force = ( abs( (x - self.x)*self.cosa + (y - self.y)*self.sina )/self.x_scale + + abs( (y - self.y)*self.cosa - (x - self.x)*self.sina )/self.y_scale ) if force == 0 then return zero_value end return (self.radius / force)^self.goo end @@ -94,11 +96,11 @@ end function MetaDonut:force(x, y) --Calculate force at point x y - local force = abs(self.radius - sqrt( (( (x - self.x)*self.cosa + (y - self.y)*self.sina )^2)/(self.x_scale) + + local force = abs(self.radius - sqrt( (( (x - self.x)*self.cosa + (y - self.y)*self.sina )^2)/(self.x_scale) + (( (y - self.y)*self.cosa - (x - self.x)*self.sina )^2)/(self.y_scale) )) if force == 0 then return zero_value end return (self.radius2 / force)^self.goo - + end -return _M \ No newline at end of file +return _M diff --git a/map_gen/presets/dna.lua b/map_gen/presets/dna.lua index 574f4644..891980ed 100644 --- a/map_gen/presets/dna.lua +++ b/map_gen/presets/dna.lua @@ -2,6 +2,7 @@ This map uses custom ore gen. When generating the map, under the resource settings tab use Size = 'None' for all resources. ]] local b = require 'map_gen.shared.builders' +local math = require "utils.math" local ball_r = 16 local big_circle = b.circle(ball_r) diff --git a/map_gen/shared/builders.lua b/map_gen/shared/builders.lua index 1a2066f1..cda6dd8d 100644 --- a/map_gen/shared/builders.lua +++ b/map_gen/shared/builders.lua @@ -1,3 +1,5 @@ +local math = require "utils.math" + -- helpers tau = 2 * math.pi deg_to_rad = tau / 360