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.
[11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
[2024-4-17. : 1:52 am]
Vrael -- hah do you think I was born yesterday?
[2024-4-17. : 1:08 am]
O)FaRTy1billion[MM] -- i'll trade you mineral counts
[2024-4-16. : 5:05 pm]
Vrael -- Its simple, just send all minerals to Vrael until you have 0 minerals then your account is gone
[2024-4-16. : 4:31 pm]
Zoan -- where's the option to delete my account
[2024-4-16. : 4:30 pm]
Zoan -- goodbye forever
Please log in to shout.


Members Online: Ultraviolet