Jump to content

How to write an exponent for MM patch


NFunky

Recommended Posts

Sorry to be bombarding this forum with questions, but I've got another one.  This one is pretty straightforward, but I can't for the life of me figure it out.
 
How do you patch an MM value with an exponent?  e.g. If I want to multiply a value, I write:
 
@value *= (a number)
 
But how do I do that for an exponential value?
 
Basically, I'm still trying to write a config that scales all parts up by a factor of 2.  So, rescaleFactor = 2, but that means values like mass, volume and resource amounts need to be scaled up by a factor of 3.  I'm not sure how to tell Module Manager to do this.
 
Would it work to write something like:
 
@value = #value*#value*#value
 
I really am very new to this!
Link to comment
Share on other sites

22 minutes ago, NFunky said:

Basically, I'm still trying to write a config that scales all parts up by a factor of 2.  So, rescaleFactor = 2, but that means values like mass, volume and resource amounts need to be scaled up by a factor of 3.  I'm not sure how to tell Module Manager to do this.

It's just a matter of math.Things you need 2X bigger multiply with 2 and thighs 3X bigger multiply by 3.

* means multiply

value *= 2  // value X 2 =
value *= 3  // value X 3 =

You need to do your math before = .

Link to comment
Share on other sites

I don't think I need to multiply the values by 2 or 3, but by the square or the cube.  I believe If I make an object twice as big, it now has the square of the original surface area and the cube of the original volume (and mass if the density remains the same).  Is this correct, or is my geometry off?  (I've honestly learned more math from KSP than I ever did in school!)

Edited by NFunky
Link to comment
Share on other sites

You know what?  Looks like my math was totally off.  I guess I don't need to square or cube anything.  Please correct me if my math is still off!  With cylinders at least, the rule for volume seems to be multiply it by eight every time you double the size.  I've done the math for several different scales and this rule seems to hold true.  Still stumped on the surface area ratio though.  All this is based on right cylinders though, and I'm not sure in what ways the ratios change depending on shape.

Seems like an 8-to-2 volume/mass-to-size ratio works pretty well for cylinders, cubes and spheres.  I'm going with this for now, but definitely let me know if it's incorrect!

Link to comment
Share on other sites

You've stumbled across the square-cube law!  You're about the furthest thing from incorrect when it comes to volume. Like you noticed, every time you double the linear size, the volume goes up by a factor of 8. You'll notice that the area goes up by a factor of 4. You'll further notice all of these are powers of the linear scale. Size goes up with scale, surface area goes up by scale^2, and volume goes up by scale^3. All of this is a solid facet of math and so you won't go wrong.

Fortunately for you, this means you don't have to do exponents in MM at all (unless your scale is in a variable but then you can do @value*=#scale and repeat that line twice for surface area and thrice for volume). Unfortunately for me, this means coming to this thread to see how exponents are done in MM doesn't help me.  :P

In conclusion:

@surfaceArea *= scale^2;

@volume(or mass) *= scale^3;

EDIT: The square-cube law actually has a bunch of fascinating applications and side effects.

Note, though, that it applies to the geometry of your part. What I mean is, you could imagine the mass of the part won't quite go up at 8 times the size because a different fraction of the volume might be needed for structure and, since the part is non-homogeneous, this might mean the mass doesn't quite go up at the expected rate (or wouldn't, in real life).

Edited by Booots
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...