Page 1 of 1

Help with "advanced" maths :O

Posted: 28 Aug 2016, 07:27
by Forboding Angel
This block causes 7 control points to be placed in a big circle all the way around the map

Code: Select all

			--Since no config file is found, we create 7 points spaced out in a circle on the map
			local angle = math.random() * math.pi * 2
			points = {}
			for i=1,7 do
				local angle = angle + i * math.pi * 2/7
				points[i] = {
					x=mapx/2 + mapx * .4 * math.sin(angle),
					y=0,
					z=mapz/2 + mapz * .4 * math.cos(angle),
					owner=nil,
					aggressor=nil,
					capture=0,
				}
			end
What I would like is for there to be 6 circles in a circle around the map and one circle be directly in the center. I can has halp?

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 08:48
by LordMuffe
not sure about the syntax, but isnt it just :

local angle = math.random() * math.pi * 2
points = {}
for i=1,6 do
local angle = angle + i * math.pi * 2/6
points = {
x=mapx/2 + mapx * .4 * math.sin(angle),
y=0,
z=mapz/2 + mapz * .4 * math.cos(angle),
owner=nil,
aggressor=nil,
capture=0,
}
und

points[7] = {
x=mapx/2,
y=0,
z=mapz/2,
}

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 09:37
by Jools
This isn't advanced math. When I saw the topic I thought: finally someone wanting to discuss Hilbert's space. But it was just trigonometry.

But advanced was in quotation marks so I guess it's all right.

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 09:57
by Silentwings
Next question, how to achieve the same result in projective space.

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 11:24
by PicassoCT
?
Scale all the resulting bitmaps with matrices?
https://www.ldv.ei.tum.de/fileadmin/w00 ... ations.pdf

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 13:34
by 8611z
how to change one number

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 13:36
by PicassoCT
Oh, a philosophical Question. You cant change a number, you can reduce it with itself to the identity (1) and then multiply it back to another number, but you never can change it.

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 14:46
by LordMuffe
PicassoCT wrote:Oh, a philosophical Question. You cant change a number, you can reduce it with itself to the identity (1) and then multiply it back to another number, but you never can change it.
If you dance with the number, the number doesn't change. The number changes you...

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 16:19
by FLOZi
Forboding Angel wrote: What I would like is for there to be 6 circles in a circle around the map and one circle be directly in the center. I can has halp?
Do you mean 6 control points in a circle with one in the centre (as LordMuffe provided) or do you literally mean multiple control points in a circle, 6 of those circles of control points (lets call them groups) and another group in the centre of the map?

Re: Help with "advanced" maths :O

Posted: 28 Aug 2016, 16:58
by LordMuffe
Don“t know how lua handels for-cycles, but it could look like this for the second case:

Code: Select all

         local angle = math.random() * math.pi * 2
         points = {}
		 		 
	for j=1,6 do 
		
         for i=1,6 do
		 
            	local anglesmall = anglesmall + i * math.pi * 2/6
		local angelbig = angelbig + j * math.pi * 2/6
					
			
            points[i+(j-1)*6] = {
               x=mapx/2 + mapx * .04 * math.sin(anglesmall) + mapx * .4 * math.sin(anglebig),
               y=0,
               z=mapz/2 + mapz * .04 * math.cos(angle) + mapx * .4 * math.cos(anglebig),
               owner=nil,
               aggressor=nil,
               capture=0,
            }
			

         for i=37,42 do
		 
            local anglesmall = anglesmall + (i-36) * math.pi * 2/6

					
			
            points[i] = {
               x=mapx/2 + mapx * .04 * math.sin(anglesmall),
               y=0,
               z=mapz/2 + mapz * .04 * math.cos(anglesmall),
               owner=nil,
               aggressor=nil,
               capture=0,
            }		
         end

Re: Help with "advanced" maths :O

Posted: 29 Aug 2016, 05:41
by Forboding Angel
FLOZi wrote:
Forboding Angel wrote: What I would like is for there to be 6 circles in a circle around the map and one circle be directly in the center. I can has halp?
Do you mean 6 control points in a circle with one in the centre (as LordMuffe provided) or do you literally mean multiple control points in a circle, 6 of those circles of control points (lets call them groups) and another group in the centre of the map?
What lordmuffe provided was what I was looking for. A little while after I posted this thread It occurred to me that that answer to the question was simple and I did it myself, doah.

I do have another issue though. For some reason, allowunitcreation is only working for configs and not for autogenerated points. Which is weird because as far as I can tell, they use the same table.

For example:

Here the config is read, and each point is put into a table called points: https://github.com/EvolutionRTS/Evoluti ... y.lua#L279

Then if the config isn't found, they are autogenerated, and put in a table called points: https://github.com/EvolutionRTS/Evoluti ... y.lua#L291


Then later on, allowcommand does it's thing on the points table, but it only works for config points: https://github.com/EvolutionRTS/Evoluti ... y.lua#L459

Any ideas why?