We’re putting the final touches on our new badges platform. Badge issuance remains temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
General

General

Discovery SpaceClaim – Scripting – Calculating distance between local coordinate systems

    • FAQFAQ
      Participant

      Script for calculating distance between 2 local coordinate systems:

      import math

      part = GetRootPart()

      #access local coordinate systems
      temp1 = part.CoordinateSystems[0]
      temp2 = part.CoordinateSystems[1]

      #access origin of coordinate systems
      coord1 = temp1.Frame.Origin
      coord2 = temp2.Frame.Origin

      #note – the values of origin are returned in Meter units

      #calculate distance between 2 coordinate systems

      x_dist = coord2[0]-coord1[0]
      y_dist = coord2[1]-coord1[1]
      z_dist = coord2[2]-coord1[2]

      dist = math.sqrt((x_dist**2)+(y_dist**2)+(z_dist**2))

      print dist

       

      Script for calculating distance between any local coordinate system and world origin:

      import math

      part = GetRootPart()

      #access local coordinate system
      temp = part.CoordinateSystems[0]

      #access origin of coordinate system
      a = temp.Frame.Origin
      print a

      #note – the values of origin are returned in Meter units

      #calculate distance from global origin
      dist = math.sqrt((a[0]*a[0])+(a[1]*a[1])+(a[2]*a[2]))
      print dist