Staredit Network > Forums > SC2 Assistance > Topic: Math help - get in here genii.
Math help - get in here genii.
May 22 2011, 12:11 am
By: NicholasBeige  

May 22 2011, 12:11 am NicholasBeige Post #1



I have a bunch of units defining an area.

I want to calculate the area in terms of a real variable.

To begin with, everyone's area is a circle, it has a center point, and a radius. This is all fine and well - the area is directly defined by the parameters at the beginning.

However, this radius can grow and shrink. That too is no problem. But when two players 'boundaries' come into contact, I want the 'stronger' players to maintain control, and the 'weaker' players to shrink.

[b]Is there a formula for say, 'connect each point[1 to 16], return size of area within those points'?[/u]

Will this formula work if the players 'area' was to expand in a manner that wasn't circular?

For example, you have a - fuck dat Imma make pitchers.


Red and Yellow have spawned against the map boundary. How would I calculate their area?


Purple has added two expansions. What is his total radius? Each expansion adds a radius of 6 to your area, but must be constructed within your existing boundary. This means that you only gain a partial increase to your total area.

Yellow has added only one expansion. What is his total radius?

Teal (center) has upgraded his main base and gained +12 radius. I know his total area to be a circle with a radius of 24 now.


Blue has been upgrading his 'strength', and has doubled his radius (like Teal did in the mid-game).
Teal is 'weaker' than Blue (since he has been expanding), and has placed an expansion encroaching his control into Blues area. However, since Teal is weaker, blue maintains his boundary, and teal's is deformed.
Purple used a special ability (I got lazy with paint) and mirror'd his current size, to the North. However, this has made him weaker than Teal, and as such, Purples boundary is deformed while Teal's maintains.

Red and Yellow left the game because spawning at the sides sucks.

Knowns:
Each boundary (initially) consists of 16 units defining the roughly circular area in which you start.
Placing an expansion creates 8 units defining a circular area near your boundary. Of these 8 units, only the ones 'outside' your current boundary are kept, the interior ones are removed.

Unknowns:
The damn area of a polygon - that can become complex as seen in the end-game.

BONUS QUESTION

Blue got attacked by Red and Green at the same time. There 'strengths' are equal, but since blue has 'unoccupied space' (free) to his left and right, his area should maintain the same value. What is his end area?

Post has been edited 1 time(s), last time on May 22 2011, 12:19 am by Cardinal.



None.

May 22 2011, 1:02 am Apos Post #2

I order you to forgive yourself!

Here is an easy solution to simplify things up a little:

Instead of calculating circles, calculate squares.
All the circles can be calculated as squares. (Height x Length)

Now, all you have to do is get the area of each individual square and subtract by the other squares. (Do the calculations on the squares.)

Now, you can draw the circle at the center of the squares with half of the height as the radius.

I don't know if that made any sense... If it did, it should simplify your work by a lot.




May 22 2011, 1:06 am Sacrieur Post #3

Still Napping

Sure, I can solve this problem. It is going to require calculus.

We can determine the areas of irregular shapes with a fixes points using polar coordinates and integration. Polar coordinates allow us to define very weird shapes, such as this:




We are able to integrate these functions as well:



---

This takes care of the area problem. The next issue rises in actually defining the shapes, which I will be working on.



None.

May 22 2011, 1:11 am Apos Post #4

I order you to forgive yourself!

Quote from Sacrieur
Sure, I can solve this problem. It is going to require calculus.

We can determine the areas of irregular shapes with a fixes points using polar coordinates and integration. Polar coordinates allow us to define very weird shapes, such as this:




We are able to integrate these functions as well:



---

This takes care of the area problem. The next issue rises in actually defining the shapes, which I will be working on.
I added a white background to your picture. (If you change it in your post, I'll remove this post.)

Post has been edited 1 time(s), last time on May 22 2011, 1:18 am by Apos. Reason: I had forgotten the second one...




May 22 2011, 1:25 am Jack Post #5

>be faceless void >mfw I have no face

Area of a sector of a circle = (0.5r^2)x with r being the radius and x being the angle of the sector (see http://www.mathwords.com/a/area_sector_circle.htm ). With that in mind, area of a big circle + area of the sector of the sector expansion circle = total area.

The red circle is just halfthe area of the circle. The yellow circle is more tricky. You're going to have the sector of the circle + two triangles formed between the sector and the wall. One side of each triangles is r, one side is shared by them and is the distance from the centre of the circle to the corner, and one is from the corner to where the circle intersects with the wall.



Red classic.

"In short, their absurdities are so extreme that it is painful even to quote them."

May 22 2011, 11:20 am Sacrieur Post #6

Still Napping

Here is what I have so far. Sorry if it is difficult to follow or understand. Most of my night was spent thinking about how to form the boundaries with equations, which came to me not an hour ago that it is only 2pi radians all the way around, and so storing a number of different, known and defined boundaries to form a more complex one would not lead to impossibilities. This is completely translatable into Cartesian coordinates. The system relies that each interval has its own shape, which either adds or subtracts from the original shape.

I have growth figured out, and would even solve your bonus problem. The radius of intervals flagged addition increase by x per second, while the radius of intervals flagged negation decrease x per second. This creates a steady growth outward on all fronts that is uniform.

More coming later. This is all very rough to give you kinda a gist of what I'm up to.

Attachments:
Trigger Math.pdf
Hits: 3 Size: 196.42kb



None.

May 22 2011, 12:22 pm NicholasBeige Post #7



Dayahm. Thanks man that's brilliant.

You make a fatal flaw though, you presume that I understand the most basic mathematical principles.

I'll read over it and study it in more detail after these two exams are out the way (Quaternary environmental change and vineyard management :awesome:).

It's great news that it is possible though, I knew it wouldn't be easy.

I was hoping for a function I could give 18 points, let it do the math, and it'll return the 'Area'. Then I'd just validate if that players Area is being encroached on and if it was, I would order those 18 points (units) to move in a way that retained the 'area' that player 'should' have. (if dat makes any sense).



None.

May 22 2011, 8:52 pm Sacrieur Post #8

Still Napping

Quote from name:Cardinal
Dayahm. Thanks man that's brilliant.

You make a fatal flaw though, you presume that I understand the most basic mathematical principles.

I'll read over it and study it in more detail after these two exams are out the way (Quaternary environmental change and vineyard management :awesome:).

It's great news that it is possible though, I knew it wouldn't be easy.

I was hoping for a function I could give 18 points, let it do the math, and it'll return the 'Area'. Then I'd just validate if that players Area is being encroached on and if it was, I would order those 18 points (units) to move in a way that retained the 'area' that player 'should' have. (if dat makes any sense).


Sorry, I have difficulty putting it into plain English. I'll try later. It's possibly, and relatively easy. You don't need to give it 18 points and have it return the area. It is able to be calculated purely through equations and integration. And even if I used approximation, then there would be no need for 18 units.



None.

May 22 2011, 9:33 pm NicholasBeige Post #9



Well I have the 18 units for visualisation purposes, so players can see their boundaries :P

The idea is that your units are automated and they cannot leave your boundary (exception being combat units which can be rallied into enemy areas).

Your boundary can grow and shrink, and deform - as shown in the OP, and that'll be done by moving the units relative to their 'centre point' (seeing as all boundary units are created in a circle around a central unit).



None.

May 22 2011, 10:35 pm Sacrieur Post #10

Still Napping

Quote from name:Cardinal
Well I have the 18 units for visualisation purposes, so players can see their boundaries :P

The idea is that your units are automated and they cannot leave your boundary (exception being combat units which can be rallied into enemy areas).

Your boundary can grow and shrink, and deform - as shown in the OP, and that'll be done by moving the units relative to their 'centre point' (seeing as all boundary units are created in a circle around a central unit).

Why not just use polygons then, instead of curves?



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2020-10-19. : 7:29 am]
C(a)HeK -- sraw531
sraw531 shouted: GGmano just fyi, might be a good idea in the future to link to the thread in the shoutbox when you reference a new thread
here it is - http://www.staredit.net/topic/18132/unread/#special
[2020-10-19. : 7:19 am]
sraw531 -- GGmano
GGmano shouted: i made a topic about it if anyone knows something about this please check the topic
just fyi, might be a good idea in the future to link to the thread in the shoutbox when you reference a new thread
[2020-10-19. : 4:46 am]
C(a)HeK -- SiberianTiger
SiberianTiger shouted: C(a)HeK yes correct it is a multiplayer map
Unfortunately, I don't have free time for multiplayer
[2020-10-18. : 10:06 pm]
SiberianTiger -- C(a)HeK
C(a)HeK shouted: GGmano I answered you as best I could
yes correct it is a multiplayer map
[2020-10-18. : 9:12 pm]
GGmano -- thanks c(a)hek
[2020-10-18. : 9:05 pm]
lil-Inferno -- mad AF
[2020-10-18. : 8:57 pm]
*KrayZee angrily uses a pen and fills in the circle for Joe Biden*
[2020-10-18. : 4:59 pm]
C(a)HeK -- GGmano
GGmano shouted: i made a topic about it if anyone knows something about this please check the topic
I answered you as best I could
[2020-10-18. : 2:01 pm]
GGmano -- i made a topic about it if anyone knows something about this please check the topic
[2020-10-18. : 2:00 pm]
GGmano -- hi all does anyone knows what difference save files does??
Please log in to shout.


Members Online: Roy, jun3hong, UndeadStar, IlyaSnopchenko