Announcement

Collapse
No announcement yet.

MATHS HELP!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MATHS HELP!

    HEY ALL

    so i have a maths problem and i need to figure out a formula. im sure its easy but its escaping me atm

    so i have a picture and i need to make sure it doesnt go outside a box

    the picture can be magnified up to 3x
    and the x and y coordinates can be changed

    at 1x magnification the max the x coordinate can be is 700

    but if i change it to 2x or 3x magnification at 700 it goes outside the box

    i need a formula that when i change the magnification to 2x or 3x it needs to make the x coordinate smaller by a percentage or a ratio or something...

    my code at the moment looks like this (user inputs are xbox (x coordinate) ybox (y coordinate) magbox (magnification)

    DrawWings(paper, xBox, yBox, magBox)

    my first thought was to do this

    DrawWings(paper, (xBox / magBox), (yBox / magBox), magBox)
    but that didnt work obviously... the / being the divide by sign.... i think im gonna end up kicking myself when i know the answer

  • #2
    And if it helps it only fits at 3x mag if the x coord is 1

    Comment


    • #3
      IF statements ftw.

      below is some code from an image resizing function i wrote in one of our sites - effectively does what you're after where args.height and args.width are the max values allowed. info.width and info.height are the existing dimensions of the image.

      Code:
      <cfif info.width gt arguments.width OR info.height GT arguments.height>
      					<cfset x=min(arguments.width/info.width, arguments.height/info.height)>
      					<cfset newwidth = x*info.width>
      					<cfset newheight = x*info.height>
      </cfif>
      my suggestion would be something like that, but put ANOTHER if statement around it which is based on the mag level, and use that to set the args.height and args.width.

      Obviously this is not the language you're working in, but the logic should be piss easy to follow.

      Comment


      • #4
        hey thanks for that but im up to week 6 of visual basic and its the first programming i have ever done in my life so what you put up there is like chinese to me...

        Comment


        • #5
          Originally posted by K_I_Z_A View Post
          hey thanks for that but im up to week 6 of visual basic and its the first programming i have ever done in my life so what you put up there is like chinese to me...
          I'll have a look at mine and help ya out on the weekend

          Comment


          • #6
            cool thanks

            Comment


            • #7
              DrawEyes(paper, CInt(xBox / magBox ^ magBox), CInt((yBox / magBox ^ magBox)), magBox)

              got it

              Comment


              • #8
                This could have been represented by a simple algebraic formula, but shit, all those visual basic variables make it so much more complicated than it needs to be!

                Comment

                Working...
                X