When dealing with math within programming, your end result is going to have variables and a bunch of things in it that make it fairly unapproachable in terms of understanding the math that's going on behind it. I personally find that writing it out on a piece of paper so that it isn't all on one line (most humans don't do math that way), replacing variable names with actual numbers, and/or a small diagram tend to help understand what's really going on.
In this case I'll take the middle suggestions of using some actual numbers instead of variable names for this. I'm going to "find the mid point" of 2.5 and 7.5. Now hopefully you intuitively know that the result is 5, but that's going to help us know where we are as we go through this. In the equation, the first part adds the two values (points or numbers, it doesn't matter) together. In our example 2.5 +7.5 is 10. In the second part of the equation our result is divided by 2, thus giving us 5. This is essentially the same operation as taking the average of those two values....Add all of them together, and divide by the number of items that make up the whole. The reason why your change from dividing by 2 to dividing by 3 doesn't work is that this particular equation isn't setup for that kind of change. But if I take a slightly different look at the equation, then maybe that modification can work. So, in the first equation we took a short cut because we knew we were only dealing with two points. Now we're going to do things a slightly longer way, but more flexible. Again, we'll use the example of 2.5 and 7.5. Now when we're looking at distances we really want to look at the amount of separation between our values rather than the values themselves because when dealing with halves, thirds, or 23/64ths the main thing we care about is that separation. We find this out by subtracting the first value from the second value; 7.5 - 2.5 = 5...Since we have that distance we can now "chop it up" however we feel like it. For thirds we can simply divide it by 3. For our example, since I'm looking for round numbers, I'm going to chop up our distance into fifths....5/5 = 1. After we've done whatever operation we want in terms of finding the the value in between, we then add the result to the first value, and then we have the actual result itself. In our case, 1/5th of the way from 2.5 to 7.5 is 3.5 Several things I should say about this. First off, it doesn't matter a whole lot which value is the first value or the second value, as long as you realize that whatever distance your generating will be from the first value your using. In the case of mid points, it doesn't matter at all, but for 3rds, or 5ths in our case, since we used 2.5 as the first value we'll get a fifth from 2.5. If we use 7.5 as the first value, then we'll get 6.5 as one fifth away from 7.5. Secondly, its really a much better idea to use multiplication instead of dividing when figuring out the amount of the distance.. The main reason is that its much faster for the computer, but in addition to that, its much easier to deal with more situations if you're multiplying. Dividing really only works out when you have halves or thirds or easy fractions. Anything beyond that and it gets far more cumbersome. So now that we understand a little bit of the math behind it, we can "translate" that back into variables within our script. Our second equation, with the values we used is going to look like this; ((7.5 - 2.5) /5) + 2.5 The translated result looks like this, with multiplication instead of division. ((Variable2 - Variable1) * 0.2) + Variable1 We could take this even further by assigning the distance between the two values (the 0.2 in the equation) to another variable and using that instead, but for now we'll leave it at that. Hope this helps. Best, Damien On Apr 28, 9:43 am, Grandtour <[email protected]> wrote: > I found a good gh VB example on wiki. In his VB , when he want to find > the middle point of two points. he use "points(i - 1) + points(i)) / > 2" > > I want to know , why this means finding the middle point of two > points???? And how does he know this???? In VB examples, I usually > find such kind of transcendent thing, how can I learn them? > > In fact, I am a new learner and want to learn VB for gh. BUT can not > find a good way to learn. I have read the 2nd primer, did not get any > point. And then I want to recite some VB example , just like the way I > learn foreign language, Is that a good way?
