Jump to content

How do I invert a point as if on a coordinate plane


Recommended Posts

So you want to enter (50, 30) and get back (30, 50)? This code will do that, but it has absolutely no error checking.

Local $point = InputBox("Enter a point", "Format: (x, y)" & @CRLF & "Min: 100" & @CRLF & "Max: 100")
MsgBox(64, "The inverted point's coordinates are:", _InvertPoint($point))

Func _InvertPoint($sPoint)
    Local $aPoint = StringSplit(StringRegExpReplace(StringStripWS($sPoint, 8), "\(|\)", ""), ",", 2)
    $sPoint = "(" & $aPoint[1] & ", " & $aPoint[0] & ")"
    Return $sPoint
EndFunc

Thanks, this code is great, If I need to I could try to add some error checking.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...