summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua28
1 files changed, 14 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua
index 3e1620dc21f..4e511746bb2 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua
@@ -14,12 +14,12 @@
--- An implementation of a quad trees.
--
-- The class QuadTree provides methods form handling quadtrees.
---
+--
local QuadTree = {
- -- Subclasses
+ -- Subclases
Particle = {},
- Cell = {}
+ Cell = {}
}
QuadTree.__index = QuadTree
@@ -45,7 +45,7 @@ end
---- Inserts a particle
+--- Inserts a particle
--
-- @param param A particle of type QuadTree.Particle
--
@@ -76,7 +76,7 @@ end
---- Particle subclass
+--- Partical subclass
QuadTree.Particle.__index = QuadTree.Particle
@@ -176,7 +176,7 @@ function QuadTree.Cell:insert(particle)
if #self.subcells == 0 then
self:createSubcells()
end
-
+
-- move particles to the new subcells
for _,existing in ipairs(self.particles) do
local cell = self:findSubcell(existing)
@@ -210,7 +210,7 @@ function QuadTree.Cell:updateMass()
for _,particle in ipairs(self.particles) do
self.mass = self.mass + particle.mass
for _,subparticle in ipairs(particle.subparticles) do
- self.mass = self.mass + subparticle.mass
+ self.mass = self.mass + subparticle.mass
end
end
else
@@ -226,27 +226,27 @@ end
function QuadTree.Cell:updateCenterOfMass()
-- reset center of mass, assuming the cell is empty
self.center_of_mass = nil
-
+
if #self.subcells == 0 then
-- the center of mass is the average position of the particles
-- weighted by their masses
self.center_of_mass = Vector.new (2)
for _,p in ipairs(self.particles) do
for _,sp in ipairs(p.subparticles) do
- self.center_of_mass = self.center_of_mass:plus(sp.pos:timesScalar(sp.mass))
+ self.center_of_mass = self.center_of_mass:plus(sp.pos:timesScalar(sp.mass))
end
self.center_of_mass = self.center_of_mass:plus(p.pos:timesScalar(p.mass))
end
self.center_of_mass = self.center_of_mass:dividedByScalar(self.mass)
else
- -- the center of mass is the average of the weighted centers of mass
+ -- the center of mass is the average of the weighted centers of mass
-- of the subcells
self.center_of_mass = Vector.new(2)
for _,sc in ipairs(self.subcells) do
if sc.center_of_mass then
- self.center_of_mass = self.center_of_mass:plus(sc.center_of_mass:timesScalar(sc.mass))
+ self.center_of_mass = self.center_of_mass:plus(sc.center_of_mass:timesScalar(sc.mass))
else
- assert(sc.mass == 0)
+ assert(sc.mass == 0)
end
end
self.center_of_mass = self.center_of_mass:dividedByScalar(self.mass)
@@ -268,7 +268,7 @@ end
function QuadTree.Cell:__tostring()
return '((' .. self.x .. ', ' .. self.y .. ') '
- .. 'to (' .. self.x + self.width .. ', ' .. self.y + self.height .. '))'
+ .. 'to (' .. self.x + self.width .. ', ' .. self.y + self.height .. '))'
.. (self.particle and ' => ' .. self.particle.name or '')
.. (self.center_of_mass and ' mass ' .. self.mass .. ' at ' .. tostring(self.center_of_mass) or '')
end
@@ -277,4 +277,4 @@ end
-- done
-return QuadTree
+return QuadTree \ No newline at end of file