# Problem3:

Given a line with possition vector u and velocity v, find the coordinates of all the points at a fix distance R from the line. Deduce from there the equation of the cylinder.

### SOLUTION:

 Let r be a point on the surface of the cylinder.

> r := [x,y,z]:
> u := vector(3): v := vector(3):
 to save typing do....

> alias(dot=innerprod, cp=crossprod);

`                                  I, dot, cp`
> w := cp( r-u, v ):
 From the formula for the distance from a point r to the line with position vector u and velocity v we have that the equation for the cylinder is:

> Cyl := dot(w,w) - dot(v,v)*R^2;

```Cyl := -2 v[3] y v[2] z + 2 v[3] y v[2] u[3] + 2 v[3] u[2] v[2] z

- 2 v[3] u[2] v[2] u[3] - 2 v[1] z v[3] x + 2 v[1] z v[3] u[1]

+ 2 v[1] u[3] v[3] x - 2 v[1] u[3] v[3] u[1] - 2 v[2] x v[1] y

+ 2 v[2] x v[1] u[2] + 2 v[2] u[1] v[1] y - 2 v[2] u[1] v[1] u[2]

2  2       2     2       2  2       2     2       2  2
+ v[3]  y  + v[3]  u[2]  + v[2]  z  + v[2]  u[3]  + v[1]  z

2     2       2  2       2     2       2  2       2     2
+ v[1]  u[3]  + v[3]  x  + v[3]  u[1]  + v[2]  x  + v[2]  u[1]

2  2       2     2        2       2       2   2         2
+ v[1]  y  + v[1]  u[2]  - (v[1]  + v[2]  + v[3] ) R  - 2 v[3]  y u[2]

2                2                2                2
- 2 v[2]  z u[3] - 2 v[1]  z u[3] - 2 v[3]  x u[1] - 2 v[2]  x u[1]

2
- 2 v[1]  y u[2]```
> Cyl := collect( Cyl, [x,y,z], distributed );
```           2     2       2     2       2     2
Cyl := v[3]  u[2]  + v[1]  u[2]  + v[2]  u[3]  - 2 v[3] u[2] v[2] u[3]

2     2                               2     2
+ v[1]  u[3]  - 2 v[1] u[3] v[3] u[1] + v[3]  u[1]

2       2       2   2                               2     2
- (v[1]  + v[2]  + v[3] ) R  - 2 v[2] u[1] v[1] u[2] + v[2]  u[1]

2              2
+ (-2 v[2]  u[1] - 2 v[3]  u[1] + 2 v[1] u[3] v[3] + 2 v[2] v[1] u[2]) x

2                                 2
+ (-2 v[1]  u[2] + 2 v[2] u[1] v[1] - 2 v[3]  u[2] + 2 v[3] v[2] u[3]) y

2              2
+ (-2 v[1]  u[3] - 2 v[2]  u[3] + 2 v[1] v[3] u[1] + 2 v[3] u[2] v[2]) z

2       2   2        2       2   2        2       2   2
+ (v[3]  + v[1] ) y  + (v[1]  + v[2] ) z  + (v[3]  + v[2] ) x

- 2 v[2] v[1] x y - 2 v[1] v[3] x z - 2 v[3] v[2] y z```
 It looks like a mess but notice that this is the equation of the GENERAL cylinder in 3D. We can pack it all into a useful function that returns the equation of the cylinder when given the vectors, u,v, r and the radius R.

> Cyl := proc(r,u,v,R)
> local x,y,z,w,eq;
> x := r[1];
> y := r[2];
> z := r[3];
> w := crossprod( r-u,v );
> eq := dotprod(w,w) - dotprod(v,v)*R^2:
> eq := collect(simplify(eq),[x,y,z],distributed);
> end:
 Let us check it

> Cyl([x,y,z],[0,0,0],[1,0,0],1);

```                                   2        2
| z |  + | y |  - 1```
 Yes, indeed the previous expression equal 0 is the equation of the cylinder of radius 1 along the x-axis. One more test,

> Cyl([x,y,z],[1,0,0],[0,0,1],R);

```                    2                                    2    2
| y |  + 1 - 2 Re(x) + | Re(x) + I Im(x) |  - R```
> assume(x, real):
> Cyl([x,y,z],[1,0,0],[0,0,1],R);
```                              2                2    2
| y |  + 1 - 2 x~ + x~  - R```
 again this is correct. It simplifies to:

Link to the commands in this file
Carlos Rodriguez <carlos@math.albany.edu>