• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Math] 'Jumping from one row of numbers to another'

Status
Not open for further replies.

Ardenian

A

Ardenian

I ran into the following problem and I would be glad if you could help me, please.
Basically, I have a certain range of numbers and a second one, imaginary linked, like this:

41424344...79

40
80120160...1560

Now I have only one of these two rows and I wish to 'call' the corresponding value from the second row.
How can I do this, with what mathematical expression ?

Note: I do not want to use array-based variables due to the huge amount of values I need
 
Last edited by a moderator:

Ardenian

A

Ardenian

Yes exactly.

Thank you!

EDIT: Well, I did not get a solution to the following ones:

80818283...119
4181121161...1521

120121123124...160
1561156215631564...1600

41424344...79
80120160200...1560

I tried to learn it searching it via the Internet, but I did not find a good site to see how I can solve this.
 
Last edited by a moderator:
Level 4
Joined
Feb 12, 2016
Messages
71
1.
Y = 41 + (X-80)*40

Doesnt match your last value (119) though, something is messed up there (should be 1601).

2.
Y = 1561 + (X-120)

Again, doesnt match your last value ... It should be 1601, just like above

3.
Y = 80 + (X - 41)*40

Your last value ....

Where do you even get these form and is there any connection to Wc3 Modding at all? :E
 

Ardenian

A

Ardenian

Thanks a lot Mercious!
Yep, I was quite tired when setting up the values so I might confuse one or another thing.

Yes, it has connection to Warcraft modding. I have a certain range of numbers and each number has a custom value. However, the Y values are not linear as the X values are, they change in certain ranges, as you can see in the tables.

However, if you don't mind, what is the easy way to get to these functions ?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
However, if you don't mind, what is the easy way to get to these functions ?
They are linear functions. You should have been taught this when around 13-14 as part of your high school mathematics. Your mathematics teacher deserves a complaint letter for teaching them so badly or not teaching them at all?

To calculate you get 2 points (which you have from the table), work out the gradient between them (using (Y1-Y2) / (X1-X2)) which is the constant "a" and then work out the Y intercept which is the constant "b".

If you explain the full scope of the problem there might be an easier solution. As far as I can tell you have the following so far.
z = f(x, y) where z is discontinuous with x and y
y = g(x) where y is discontinuous with x every 40 units

If you could explain the purpose of function f(x, y) and why you need g(x) it might help solving the problem more efficiently.
 

Ardenian

A

Ardenian

Alright, lets try this:

X1 = 124 X2 = 248
Y1 = 456 Y2 = 1824

a = ( 456 - 1824)/( 124 - 248) = 11

f(x) = ax + b
-> 456 = 11*124 + b
b = - 908
-> Y = 11X + 908

Hm, seems this is not how it works
 
Level 13
Joined
Jan 2, 2016
Messages
978
I made you a program for calculating these.
You just need to fill in the orange fields to get the formula, and then fill the yellow fields with other values (x) to get their y's.
I even locked the cells so you can't break it :D
(it's in zip, cuz Hive doesn't like excel files)
 
Last edited:

Ardenian

A

Ardenian

I made you a program for calculating these.
You just need to fill in the orange fields to get the formula, and then fill the yellow fields with other values (x) to get their y's.
I even locked the cells so you can't break it :D
(it's in zip, cuz Hive doesn't like excel files)
Save for dummies like me, eh ;)

Wow, thank you! Now I realized it can easily be done this way, using an excel table.. I am surely going to make use of it!
 

Ardenian

A

Ardenian

Update:

Here is the visualization of my problem:


In difference to a common square, my square consists of a limited amount of points.


attachment.php


That being said, the border consists of 156 points


attachment.php


These are the X values of my value tables

The Y values we get from this one:


attachment.php


X 1 2...40

Y
12...40
-> We can ignore the Northern side

Southern Site ->

X 41 42...78

Y
80120...1560

a = (Y1-Y2) / (X1-X2)) = ( 80 - 120)/(41-42) = 40

b = Y - a*X = -1560

Correct

-> Y = 40*X - 1560

-> Western Site

X 79 80...116

Y
4181...1521

a = (Y1-Y2) / (X1-X2)) = ( 41 - 81)/(79-80) = 39

b = Y - a*X = -3040

-> Y = 39*X - 3040

Correct


-> Southern Site

X 117 118...156

Y
15611562...1600


a = (Y1-Y2) / (X1-X2)) = ( 1561 - 1562)/(117-118) = 1

b = Y - a*X = 1444

-> Y = 1*X + 1444

Correct
 
Last edited by a moderator:
Status
Not open for further replies.
Top