# Python code snippet for creating a horizontal curve tool
def create_horizontal_curve(tangent1, tangent2, radius, spiral_length):
"""
Creates a horizontal curve (circular arc + spiral) between two tangents.
:param tangent1: First tangent point (x1, y1)
:param tangent2: Second tangent point (x2, y2)
:param radius: Radius of the circular arc
:param spiral_length: Length of the spiral (transition curve)
:return: List of points representing the curve
"""
# Calculate the center of the circular arc
center_x = (tangent1[0] + tangent2[0]) / 2
center_y = (tangent1[1] + tangent2[1]) / 2
# Create the circular arc
circular_arc_points = []
for angle in range(0, 181): # Half of the circle
x = center_x + radius * cos(radians(angle))
y = center_y + radius * sin(radians(angle))
circular_arc_points.append((x, y))
# Create the spiral (transition curve)
spiral_points = []
for s in range(0, spiral_length):
x = tangent1[0] + s * (tangent2[0] - tangent1[0]) / spiral_length
y = tangent1[1] + s * (tangent2[1] - tangent1[1]) / spiral_length
spiral_points.append((x, y))
# Combine circular arc and spiral points
curve_points = circular_arc_points + spiral_points
return curve_points
# Example usage
tangent1 = (0, 0)
tangent2 = (10, 0)
radius = 5
spiral_length = 10
horizontal_curve = create_horizontal_curve(tangent1, tangent2, radius, spiral_length)
# Print the points of the horizontal curve
for point in horizontal_curve:
print(point)