Assignment #13



Question #1:
In three dimensions any three points are coplanar, that is, there exists a plane for which all the points lie in that plane. However if you have 4 or more points we would like to test if those points are co-planar. Write a function is_coplanar which accepts a list or a set of points and tests if those points all lie on the same plane (that is your function will return true if the points are coplanar and false if not). You may assume that if there are 3 or fewer points that they are coplanar. If there are more than 3 points then one way of testing this is to take a normal vector to the plane containing the first 3 points and verifying that it is perpendicular to the vector containing the first and 4th points, first and the 5th points, etc.

Examples: The following sets of points all lie on the same plane $$\{(0,0,0),(1,1,1),(1,0,1)\}$$ $$\{(1,-1,0),(0,1,-1),(1,0,-1),(3,-1,-2)\}$$ $$\{(0,0,0),(1,0,0),(0,1,0),(3,4,0),(2,1,0),(5,1,0)\}$$ $$\{(1,1,1),(2,1,1),(1,2,1),(4,5,1),(3,2,1),(6,2,1)\}$$ $$\{(4,-1,1),(3,1,0),(4,0,0),(6,-1,-1)\}$$ The following sets of points all do not lie on the same plane. $$\{(0,0,0),(1,1,1),(1,0,1),(2,-1,0)\}$$ $$\{(1,-1,0),(0,1,-1),(2,-1,0),(1,0,-1),(3,-1,-2)\}$$ $$\{(0,0,0),(1,0,0),(0,1,0),(3,4,0),(2,1,0),(5,1,0),(1,1,1)\}$$ $$\{(1,1,1),(0,0,0),(2,1,1),(1,2,1),(4,5,1),(3,2,1),(6,2,1)\}$$ $$\{(4,-1,1),(3,1,0),(0,2,3),(4,0,0),(6,-1,-1)\}$$

Question #2:
The vector $( c \cdot cos(\theta), c \cdot sin(\theta), - a \cdot cos(\theta) -b \cdot sin(\theta))$ is perpendicular to the vector $(a,b,c)$ (because the dot product of these two vectors is $0$). If $\theta$ ranges between $0$ and $2 \pi$ then it sweeps out a parametric curve of an ellipse and the plane where the points of the ellipse lies is perpendicular to the vector $(a,b,c)$. If you divide by the length of this vector then it will sweep out a parametric curve of a circle of radius $1$ centered at the origin and this circle is in a plane perpendicular to $(a,b,c)$.

Example: A circle in a plane perpendicular to the vector between $(0,0,0)$ and $(1,1,3)$.
> with(plottools): > dd:=sqrt(9+(sin(theta)+cos(theta))^2);
> A:=spacecurve( [3*cos(theta)/dd,3*sin(theta)/dd,(-cos(theta)-sin(theta))/dd], theta=0..2*Pi, numpoints=100):
> display(A,display(line([0,0,0],[1,1,3]),scaling=constrained, linestyle=solid, color=red));


Given a parametric curve in 3-d $(x(t), y(t), z(t))$ such that $(x'(t), y'(t), z'(t))$ is never $(0,0,0)$, write a function tubify (pronounced toob-a-fi) which gives the equation of the surface $({\tilde x}(t,\theta), {\tilde y}(t, \theta), {\tilde z}(t,\theta))$ of a tube that follows the curve and for each value of $t_0$ on the curve, the equation $({\tilde x}(t_0,\theta), {\tilde y}(t_0, \theta), {\tilde z}(t_0,\theta))$ is a circle of radius $1$, centered at $(x(t_0), y(t_0), z(t_0))$ which lies on a plane perpendicular to $(x'(t_0), y'(t_0), z'(t_0))$.

Example:
> swish:=[30*t*(2*Pi-t)*cos(3*t)/(2*Pi)^2,30*t*(2*Pi-t)*sin(3*t)/(2*Pi)^2,10*cos(t/2)];
> spacecurve(swish,t=0..2*Pi);

> plot3d(tubify(swish), theta=0..2*Pi,t=0..2*Pi,grid=[100,100],scaling=constrained);






You should open up a new worksheet and start from scratch. You will have to save your work in a file and upload that file on to the course moodle. Your solution should be a sequence of commands where it is easy to change the input string and after you execute the sequence of commands you should have the correct output string. Please add documentation to your worksheet to explain how it works. Just a few sentences is sufficient, but imagine that you were opening up the worksheet for the first time and wanted to know what it did. You will be marked down if what you write is not clear and coherent.

You should finish your assignment by Wednesday, November 29 by 11:59pm. Assignments submitted after this date will be assessed a penalty of 10% per day.