Skip to content

Instantly share code, notes, and snippets.

@hernandohhoyos
Created August 1, 2024 18:02
Show Gist options
  • Save hernandohhoyos/91e79cc6afe2b184469da5bbf138e6bd to your computer and use it in GitHub Desktop.
Save hernandohhoyos/91e79cc6afe2b184469da5bbf138e6bd to your computer and use it in GitHub Desktop.
Calcular la posición de un segundo punto en un espacio 2D dados un punto inicial, una distancia, un eje, una altura y un ángulo
import math
import numpy as np
def calculate_neigbor_vector(a, distance, degrees, height=0):
a = np.array(a)
radians = math.radians(degrees)
x2 = a[0] + distance * math.cos(radians)
y2 = a[1] + distance * math.sin(radians)
z2 = a[2] + distance * math.sin(radians) * height
return np.array((x2, y2, z2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment