You will write three functions that work on two lines in space. They find the scalar triple product, sort the lines into three kinds and find the shortest distance between them. The functions for the dot and cross product are given.
The idea. A line is a point and a direction . The lines are parallel when . Otherwise they intersect when , and they are skew when it is not zero.
Your tasks.
triple(a1, b1, a2, b2). Return .kind(a1, b1, a2, b2). Return "parallel", "intersecting" or "skew".distance(a1, b1, a2, b2). Use the skew formula, or the parallel formula when the lines are parallel.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…