Rotate vector question [SOLVED]

Hi there,

I wanted to use the RotateVector method but it does not work somehow.

I would like to rotate the tangent of the curve (at the start point) by 90 degree based on the normal vector of the curve plane. Finally I have got this result:

Rotate vector.py (969 Bytes)
Rotate vector.3dm (25.7 KB)
Rotate%20vector

Hi @onrender,

Try this:

import rhinoscriptsyntax as rs

# Select a planar curve
curve_id = rs.GetObject("Select planar curve", rs.filter.curve)
# Get the curve's domain
curve_dom = rs.CurveDomain(curve_id)
# Get the curve's starting point
start_point = rs.CurveStartPoint(curve_id)

# Get tangent direction at starting point
tangent_dir = rs.CurveTangent(curve_id, curve_dom[0])
# Create a point offset from the start point in the tangent direction
tangent_point = rs.PointAdd(start_point, tangent_dir)
# Add a line and select it
tangent_line_id = rs.AddLine(start_point, tangent_point)
rs.SelectObject(tangent_line_id)

# Get the normal direction of the planar curve's plane
normal_dir = rs.CurveNormal(curve_id)
# Create a point offset from the start point in the normal direction
normal_point = rs.PointAdd(start_point, normal_dir)
# Add a line and select it
normal_line_id = rs.AddLine(start_point, normal_point)
rs.SelectObject(normal_line_id)

# Rotate the tangent vector 90 degress around the normal vector
rotate_dir = rs.VectorRotate(tangent_dir, 90.0, normal_dir)
# Rotate the tangent vector 90 degress around the normal vector
rotate_point = rs.PointAdd(start_point, rotate_dir)
# Add a line and select it
rotate_line_id = rs.AddLine(start_point, rotate_point)
rs.SelectObject(rotate_line_id)

I should add that you can also use rs.VectorCrossProduct in this case.

– Dale

Thank you. I made some tests and it makes sense now.