Created
December 30, 2014 01:38
-
-
Save feomike/8205b9628a9a70f0602e to your computer and use it in GitHub Desktop.
offsetting a point by 90 degrees
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#offset the points to the appropriate side based on the direction of the arc and the | |
#side that these addresses should be on. this function uses trigonometry to move a | |
#a delta x and and delta y. | |
#then return new X and Y as a list | |
#arguments: | |
#-myX is the X value of the input point | |
#-myY is the Y value of the input point | |
#-mySide is the side of the line (left or right) | |
#-myAz is the azimuth direction of the line (0-360) | |
def offset_pt(myX, myY, mySide, myAz): | |
#we are offsetting by 5 meters | |
theOffset = 10 | |
#a perpendicular line on the left side is always -90 degrees from the original | |
#direction of the line | |
if mySide == "left": | |
newDir = myAz - 90 | |
#a perpendicular line on the right side is always +90 degrees from the original | |
#direction of the line | |
if mySide == "right": | |
newDir = myAz + 90 | |
#do do some basic trig to get the delta X and the delta y of the new point. | |
#assuming the new perpendicular line is the hypotenuse, then the new point is | |
#delta X is the distance along the X access or the adjacent line in a right triangle | |
#here, we have to use the math.radians to convert the new direction to and then | |
#pass that to the sin method; similarly, delta Y is the the opposite line in a right | |
#triangle, so we use cosine of that angle to acquire this distance. | |
newX = myX + (math.sin(math.radians(newDir)))*theOffset | |
newY = myY + (math.cos(math.radians(newDir)))*theOffset | |
return ([newX, newY]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment