func drawline(starting_point, finishing_point):
var width = 0.1
var diference_vector = finishing_point - starting_point
var diference_vector_norm = sqrt(pow(diference_vector[0],2.0) + pow(diference_vector[1],2.0) + pow(diference_vector[2],2.0))
var normalized_difference_vector
if diference_vector_norm != 0:
normalized_difference_vector = Vector3(diference_vector[0]/diference_vector_norm, diference_vector[1]/diference_vector_norm, diference_vector[2]/diference_vector_norm)
else:
normalized_difference_vector = Vector3(0,0,0)
var s1 = Vector3(0, width, -width)
var s2 = Vector3(0, width, width)
var s3 = Vector3(0, -width, width)
var s4 = Vector3(0, -width, -width)
var x_vec = Vector3(1,0,0)
var axis_vector = normalized_difference_vector.cross(x_vec)
var axis_vector_norm = sqrt(pow(axis_vector[0],2.0) + pow(axis_vector[1],2.0) + pow(axis_vector[2],2.0))
if axis_vector_norm != 0:
var normalized_axis_vector = Vector3(axis_vector[0]/axis_vector_norm, axis_vector[1]/axis_vector_norm, axis_vector[2]/axis_vector_norm)
var theta = acos(x_vec.dot(normalized_difference_vector))
var matrix_0_0 = cos(theta) + (pow(normalized_axis_vector[0],2.0) * (1-cos(theta)))
var matrix_0_1 = (normalized_axis_vector[0] * normalized_axis_vector[1] * (1-cos(theta))) - (normalized_axis_vector[2] * sin(theta))
var matrix_0_2 = (normalized_axis_vector[0] * normalized_axis_vector[2] * (1-cos(theta))) + (normalized_axis_vector[1] * sin(theta))
var matrix_1_0 = (normalized_axis_vector[1] * normalized_axis_vector[0] * (1-cos(theta))) + (normalized_axis_vector[2] * sin(theta))
var matrix_1_1 = cos(theta) + (pow(normalized_axis_vector[1],2.0) * (1-cos(theta)))
var matrix_1_2 = (normalized_axis_vector[1] * normalized_axis_vector[2] * (1-cos(theta))) - (normalized_axis_vector[0] * sin(theta))
var matrix_2_0 = (normalized_axis_vector[2] * normalized_axis_vector[0] * (1-cos(theta))) - (normalized_axis_vector[1] * sin(theta))
var matrix_2_1 = (normalized_axis_vector[2] * normalized_axis_vector[1] * (1-cos(theta))) - (normalized_axis_vector[0] * sin(theta))
var matrix_2_2 = cos(theta) + (pow(normalized_axis_vector[2],2.0) * (1-cos(theta)))
var matrix = Transform(Vector3(matrix_0_0, matrix_0_1, matrix_0_2), Vector3(matrix_1_0, matrix_1_1, matrix_1_2), Vector3(matrix_2_0, matrix_2_1, matrix_2_2), Vector3(0,0,0))
var a1 = matrix.basis.xform(s1) + starting_point
var a2 = matrix.basis.xform(s2) + starting_point
var a3 = matrix.basis.xform(s3) + starting_point
var a4 = matrix.basis.xform(s4) + starting_point
var b1 = matrix.basis.xform(s1) + finishing_point
var b2 = matrix.basis.xform(s2) + finishing_point
var b3 = matrix.basis.xform(s3) + finishing_point
var b4 = matrix.basis.xform(s4) + finishing_point

You are watching: How to calculate (or rotate) four points in a plane perpendicular to a line. Info created by GBee English Center selection and synthesis along with other related topics.