Staredit Network

Staredit Network -> UMS Assistance -> Mathematical functions
Report, edit, etc...Posted by Zeratul_101 on 2006-06-26 at 23:06:09
how would you reduce something to lowest terms?

eg. 4 to 1
......8.....2

new question:

this is concerning 'reflective'(correct term?) properties. like how light bounces off a mirror.

thanks to DTBK, i know the conversion is x = -y(where y = x), but from what i gather, that only applies to perfect horizonal/vertical slopes. how about a reflective plane at a 1/2 and 1 /-2 slope? how does it affect the conversion then? if at all.
Report, edit, etc...Posted by KinG_JaKe on 2006-06-26 at 23:09:58
you should definitly edit that and restate the question or something... i have no clue what u r talking about --are u even talking about in maps or should this be moved to null... divide? ...i just not getting the question
Report, edit, etc...Posted by Zeratul_101 on 2006-06-26 at 23:17:02
you know about reducing to lowest terms?
Report, edit, etc...Posted by yoni45 on 2006-06-26 at 23:18:49
In general, or in sc? =/
Report, edit, etc...Posted by Zeratul_101 on 2006-06-26 at 23:19:24
in sc
Report, edit, etc...Posted by yoni45 on 2006-06-26 at 23:23:01
heh got me =/

What would this be used for?
Report, edit, etc...Posted by Zeratul_101 on 2006-06-27 at 01:15:50
sloping and perpendicular angles. i need to compare negative reciprocoal, but since the Target and Source points can be any length, distance and angle away from each other, a slope that can be reduced but isn't will appear false when compared to its reduced negative reciprocoal. also, keep in mind, this is for isometric walls so the slopes are 1/2 and -1/2 (or 1/-2, w/e you prefer).

compare slopes of 1/2 and -2/1. they are each other's negative reciprocal and everyone lives happily ever after.

but in this case:

1/2 and -8/4

simply because the right slope isn't reduced, the equation comes out false(and in the case of my map, you have grenades going through walls). -8/4 expects a negative reciprocal of 4/8, while 1/2 expects -2/1.

ADDITION:
can someone who knows people like (u)bolt_head and tuxedo templar tell them to come and take a look at this?
Report, edit, etc...Posted by yoni45 on 2006-06-27 at 02:57:20
QUOTE(Zeratul_101 @ Jun 26 2006, 11:15 PM)
sloping and perpendi...
[right][snapback]514056[/snapback][/right]


Alright well, if this is possible, i can imagine it'd be quite the convoluted system to go about it... =/
Report, edit, etc...Posted by (U)Bolt_Head on 2006-06-27 at 04:57:44
http://www.staredit.net/index.php?tutorial=34

To do actual mathmatical reducing use the calculator stuff tux talks about in his tutorial.

But dependant on your situation it may be easier to do other things. Like have the answer predetermaned or to edit the way that your numbers are imputed so you don't have non reduced fractions.

QUOTE
but since the Target and Source points can be any length, distance and angle away from each other


Oh yeah I see what your doing now.
Report, edit, etc...Posted by in_a_biskit on 2006-06-27 at 05:28:31
haha, if you want to get mathematical, you want to find the Greatest Common Divisor d of two numbers a and b, and then the ratio a:b in lowest terms is a/d:b/d.

Now, if you're only looking at small numbers, say, you don't expect either a or b to be greater than 10, then it may be easiest to just manually have a trigger case for each possible combination. (In this case, I'd estimate less than 30 distinct triggers).
--

However, if you want to account for a very large number of cases (say if a and b potentially have unlimited magnitude), then... you can find d by trial and error... try translating this into triggers: tongue.gif
CODE
test_val = min(a,b);
d = 0;

while ( d==0 && test_val > 0 )
   if ( remainder(a,test_val)==0 && remainder(b,test_val)==0 )
       d == test_val;
   else
       test_val == test_val - 1;
   end
end
[sub]Written in the language MATLAB, for those who were wondering =P[/sub]

Alternatively, you can try to use Euclid's Algorithm to find the greatest common divisor d. Euclid's algorithm works at the speed of light, and looks like this:
Divide a by b and find the remainder r[sub]1[/sub]. Then divide b by r[sub]1[/sub] and find the remainder r[sub]2[/sub]. Divide r[sub]1[/sub] by r[sub]2[/sub] and find the remainder r[sub]3[/sub], and so on. Continue until r[sub]n[/sub] = 0, and then r[sub]n-1[/sub] = d, the lowest common denominator.
[codebox]Example: find the greatest common divisor of 138 and 96.

138 = 1*96 + 42 (i.e. r[sub]1[/sub] = 42)
96 = 2*42 + 12
42 = 3*12 + 6
12 = 2*6 (+ 0)

So the greatest common divisor of 138 and 96 is 6.
So the ratio 138:96 in lowest terms is 138/6:96/6 = 23:16[/codebox]I will be very impressed with anyone who can put this in their map biggrin.gif
Report, edit, etc...Posted by Zeratul_101 on 2006-06-27 at 09:40:22
QUOTE(yoni45 @ Jun 27 2006, 12:56 AM)
Alright well, if this is possible, i can imagine it'd be quite the convoluted system to go about it... =/
[right][snapback]514179[/snapback][/right]


well, i can detect slope already. although it uses an actual gridding system so its nothing spectacular

ADDITION:
QUOTE(in_a_biskit @ Jun 27 2006, 03:28 AM)
However, if you want to account for a very large number of cases (say if a and b potentially have unlimited magnitude), then... you can find d by trial and error... try translating this into triggers: tongue.gif
[right][snapback]514212[/snapback][/right]


thats what i was originally thinking, but it would take so many loops before it would find the correct reduction that you'd see the grenade travelling for 2 seconds and waiting for instructions for the next 10

QUOTE(in_a_biskit @ Jun 27 2006, 03:28 AM)
Alternatively, you can try to use Euclid's Algorithm to find the greatest common divisor d.  Euclid's algorithm works at the speed of light, and looks like this:
Divide a by b and find the remainder r[sub]1[/sub].  Then divide b by r[sub]1[/sub] and find the remainder r[sub]2[/sub].  Divide r[sub]1[/sub] by r[sub]2[/sub] and find the remainder r[sub]3[/sub], and so on. Continue until r[sub]n[/sub] = 0, and then r[sub]n-1[/sub] = d, the lowest common denominator.
[codebox]Example: find the greatest common divisor of 138 and 96.

  138 = 1*96 + 42    (i.e. r[sub]1[/sub] = 42)
   96 = 2*42 + 12
   42 = 3*12 +  6
   12 = 2*6 (+ 0)

So the greatest common divisor of 138 and 96 is 6.
So the ratio 138:96 in lowest terms is 138/6:96/6 = 23:16[/codebox]I will be very impressed with anyone who can put this in their map biggrin.gif
[right][snapback]514212[/snapback][/right]


i don't even want to get into multiplication for this, maybe a project for a later date.


i think i've decided on the simplest method, have a 7x7 location around the origin point and only let the target point travel in this 7x7 area. this way, the only slopes that need reducing(as far as i can think) are the ones with direct routes to the corners. using this system, i'd only need to reduce for eight predetermine location. it won't be quite what i wanted, but it'll have to do.

unless someone come up with a very fast method. by very fast, i mean within 12 loops(one second).

regardless, thanks for the help anyways.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-23 at 19:56:55
on second thought in a biskit, i just might use your proposal. now that i've created a much better trigger organization system, i just might be able to do it, but it'll still be tough. if i can implement it, i'll give you credit in my doom 3 map.

just wth was i thinking when i decided to settle for a 7x7 limitation. blink.gif

okay, i have another question concerning reflection off of sloped surfaces. refer to the first post.
Report, edit, etc...Posted by Rantent on 2006-07-23 at 20:45:39
Your trying to make a bounce?
For like a projectile?

Well I can sorta help out with it a little bit as I tried tackling this same problem (Finding a way to have projectiles bounce) a while ago. Slopes of anything other then horazontal, perpendicular and 45° angle are quite difficult, and I never got them to work properly, the best result I got for the 45° was simply combining it as a horazontal and vertical reflection. To do other angles you would simply put more characteristics of either horazontal or verticle reflections into the bounce. I suppose 60 and 30° angles are possible, and so would be any other angle, but the detection of the angle would be more difficult the higher degree of precision it became.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-23 at 20:47:31
actaully, i'm not really using angles, i'm using slopes(like on a grid). sorry if this confused you.
Report, edit, etc...Posted by Rantent on 2006-07-23 at 20:52:15
Well slopes are basically defined by angles. A slope of x=y is at an angle of 45°.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-23 at 20:54:36
okay, but in my map, the grid isn't sensitive enough to require angles. each grid value is one tile away from any other grid value.

in 3x3 areas:

i'd either have 4 in each corner or one in the middle.
Report, edit, etc...Posted by Tuxedo Templar on 2006-07-23 at 21:14:08
If you want to see a working implementation of slope, check the link in my sig for my maps for one called Gunner System [v2.0].

Note that's not the same as my more recent Gunner System v2 prototype, mind you. [v2.0] was posted over a year ago.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-24 at 01:34:14
mind explaining how the hell that works... and did you have to leave so many uncommented trigs?
Report, edit, etc...Posted by Tuxedo Templar on 2006-07-24 at 02:04:05
Yes. Most of the uncommented triggers are just repeating ones with subtle differences between them. Waste of strings to add comments to each of them.

Most of the tricks used for that one are covered in the tutorials section here. Look for Binary Countoff and Counter Arithmetic.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-24 at 02:54:25
damnit, i don't get it. sad.gif and i didn't get any results for binary cutoff, but i generally alrady know what that is. the differences aren't very 'subtle' when you didn't make the map lol.

could you just tell me what you used to center locations on? was it mobile grid based? caused you missed a few directions.
Report, edit, etc...Posted by Rantent on 2006-07-24 at 07:37:44
Tux's method may be confusing, I myself had mulled over how it worked for quite some time before I got it.

One method, I use, was made originally by in_a_bisket.
Projectile Plotter
My expansion of it.
My version should have rather well labeled triggers, although any ammount of labels doesn't make them much easier to see what is going on.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-28 at 01:14:17
reading the counter arithmetic tutorial, can someone explain to me what is the point of binary cutoffs?

ADDITION:
from my understanding of it, it jsut tells you if certain numbers exist.
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-28 at 02:15:53
The point is to allow one to manipulate any value a death counter can be (limited by the range of the highest power of 2 you are starting with) in one trigger cycle.

And by manipulate, I mean many different things such as, duplicating a value, dumping one value from one death counter to another, comparisons, and those mathematical functions. And also anything having to do with binary.

It's about the closest you will get to being able to use deathcounters as variables.

Here's what the Starcraft Mapping Glossary topic says:

QUOTE
# Counter Copy: Also refered to as Binary Countoff, this is a technique of copying one counter to another by counting off in binary amounts (2, 4, 8, 16... 1024, 2048... so on). A somewhat advanced technique.


It's hard to explain, and the easiest way to understand them is to look at an example, such as Tuxedo-Templar's Binary Calculator map. It pretty much shows what the counter arithmetic tutorial is explaining.
Report, edit, etc...Posted by in_a_biskit on 2006-07-28 at 06:02:05
QUOTE(Zeratul_101 @ Jun 27 2006, 01:05 PM)
thanks to DTBK, i know the conversion is x = -y(where y = x), but from what i gather, that only applies to perfect horizonal/vertical slopes. how about a reflective plane at a 1/2 and 1 /-2 slope? how does it affect the conversion then? if at all.
[right][snapback]514015[/snapback][/right]

Hm. Just a quick comment about reflecting off "easy angles"...

Suppose you're moving initially with slope y/x (to the top right in the following example):
CODE
Example
         * }
      o  x } y = 1
   o     x }
oxxxxxxxxx }
~~~~~~~~~~
   x = 3
              (slope = 1/3)


If you now reflect off a horizontal surface, the new slope will be (-1)/3 - that is, y goes to -y.

If you reflect off a vertical surface, the new slope will be 1/(-3) - that is, x goes to -x.

If you reflect off a surface at 45 degrees (sloping up to the right):
CODE

            *


           ox
               - (slope line should be 45deg)
              -
          o x- } y2 = 3
            -
           -
         *-xx  } x2 = 1  (new slope = 3/1)
      o  -
   o    -x
oxxxxxx-xx (original slope = 1/3)
      -
     -

The new slope is 3/1 - that is, x goes to y, and y goes to x.

Hopefully you can see that if the slope were at 135 degrees (sloping upwards to the left), the new slope would be (-3)/(-1) - that is, x goes to -y and y goes to -x.

Any other angle is really very tricky to reflect off.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-28 at 11:41:37
QUOTE(MoonlighTurtle @ Jul 28 2006, 12:15 AM)
The point is to allow one to manipulate any value a death counter can be (limited by the range of the highest power of 2 you are starting with) in one trigger cycle.

And by manipulate, I mean many different things such as, duplicating a value, dumping one value from one death counter to another, comparisons, and those mathematical functions. And also anything having to do with binary.

It's about the closest you will get to being able to use deathcounters as variables.

Here's what the Starcraft Mapping Glossary topic says:
It's hard to explain, and the easiest way to understand them is to look at an example, such as Tuxedo-Templar's Binary Calculator map. It pretty much shows what the counter arithmetic tutorial is explaining.
[right][snapback]533204[/snapback][/right]


would you mind explaing how using the higher binary values is better than using the lower orginal values? mind giving an example?

ADDITION:
IRT in_a_biskit

lol, thats not even the hard part, try doing it off of a sloped 'surface.' i'm using a four point data storage system to store my slope info, so it should be a simple matter of transferring stored info from the 'positive side' side to the 'negative side.' but thanks for the heads up about x = -y and all of that

ADDITION:
wait a sec, what are you saying in that second diagram? isn't an agle of 45 = a slope of 1?
Next Page (1)