COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Perpendicular Lines in 3d Space

• Email
• Follow

```Hi,

I have a two points on a line (x1,y1,z1) and (x_a,y_a,z_a). This line is the axis of a random cylinder. I have a 3rd point (x_p,y_p,z_p).  I need to create a plane perpendicular to the line between the axis and the 3rd point and passing through the 3rd point and exclude all the points on and beyond the plane away from the cylinder.

The code i used for generating the cylinder is given below:

n = 100;                                                                   % No: of points on the cylinder.
h = rand(n,1)*60;                                                      % Height of Cylinder.
r = 10+(rand(n,1)-0.9)*0.8;                                        % Radius of Cylinder.
theta = 360*rand(n,1);
x=r.*cos(theta);
y=r.*sin(theta);

Any help/suggestions is greatly appreciated. Thank You.
```
 0

See related articles to this posting

```"Deepak " <deepak.tss@gmail.com> wrote in message <ik3eko\$8fp\$1@fred.mathworks.com>...
> Hi,
>
> I have a two points on a line (x1,y1,z1) and (x_a,y_a,z_a). This line is the axis of a random cylinder. I have a 3rd point (x_p,y_p,z_p).  I need to create a plane perpendicular to the line between the axis and the 3rd point and passing through the 3rd point and exclude all the points on and beyond the plane away from the cylinder.
>

The equation of the plane is

dot(planeNormal, [x;y;z])= planeDisplacement

where planeNormal and planeDisplacement are determined by

uAxis=[x_a; y_a; z_a] - [x1;y1;z1];
up=[x_p; y_p; z_p] - [x1;y1;z1];

planeNormal=cross( cross(uAxis,up), uAxis);

planeDisplacement = dot(planeNormal, [x_p; y_p; z_p]);

> The code i used for generating the cylinder is given below:
>
> n = 100;                                                                   % No: of points on the cylinder.
> h = rand(n,1)*60;                                                      % Height of Cylinder.
> r = 10+(rand(n,1)-0.9)*0.8;                                        % Radius of Cylinder.
> theta = 360*rand(n,1);
> x=r.*cos(theta);
> y=r.*sin(theta);
>
>
> Any help/suggestions is greatly appreciated. Thank You.
```
 0

```"Matt J" wrote in message <ik3mv3\$c86\$1@fred.mathworks.com>...
> "Deepak " <deepak.tss@gmail.com> wrote in message <ik3eko\$8fp\$1@fred.mathworks.com>...
> > Hi,
> >
> > I have a two points on a line (x1,y1,z1) and (x_a,y_a,z_a). This line is the axis of a random cylinder. I have a 3rd point (x_p,y_p,z_p).  I need to create a plane perpendicular to the line between the axis and the 3rd point and passing through the 3rd point and exclude all the points on and beyond the plane away from the cylinder.
> >
>
> The equation of the plane is
>
>    dot(planeNormal, [x;y;z])= planeDisplacement
>
> where planeNormal and planeDisplacement are determined by
>
>
> uAxis=[x_a; y_a; z_a] - [x1;y1;z1];
> up=[x_p; y_p; z_p] - [x1;y1;z1];
>
> planeNormal=cross( cross(uAxis,up), uAxis);
>
> planeDisplacement = dot(planeNormal, [x_p; y_p; z_p]);
>
>
>
>
>
> > The code i used for generating the cylinder is given below:
> >
> > n = 100;                                                                   % No: of points on the cylinder.
> > h = rand(n,1)*60;                                                      % Height of Cylinder.
> > r = 10+(rand(n,1)-0.9)*0.8;                                        % Radius of Cylinder.
> > theta = 360*rand(n,1);
> > x=r.*cos(theta);
> > y=r.*sin(theta);
> >
> >
> > Any help/suggestions is greatly appreciated. Thank You.

Hi Matt,

I was able to get the plane. But I also need to ignore any points on  and beyond the plane away from the center of the cylinder. Previously for a 2d circle, I had to incorporate the same method of finding the perpendicular to the line from center of circle to the nearest point. In order to ignore points on and beyond the line away from the center of the circle, i used a code provided on this forum as given below:

v=[x_1(min_p) y_1(min_p)];               %%x_1(min_p),y_1(min_p) is the closest point
center of circle. x_1 and y_1 are all points.
keep=v*[x_1;y_1] < v*v';

plot(x_1(keep),y_1(keep),'or')

But when i try this same technique for 3d :

v=[X1(min_p) Y1(min_p) Z1(min_p)];
keep=v*[X1;Y1;Z1] < v*v';
plot3(X1(keep),Y1(keep),Z1(keep),'or')

i get a cylinder of 'keep' points instead of 'keep' point on one side of the plane.

Thanks
```
 0
Reply deepak.tss (39) 2/23/2011 9:30:21 PM

```"Deepak " <deepak.tss@gmail.com> wrote in message <ik3u9d\$7i6\$1@fred.mathworks.com>...
>
> But when i try this same technique for 3d :
>
> v=[X1(min_p) Y1(min_p) Z1(min_p)];
> keep=v*[X1;Y1;Z1] < v*v';
> plot3(X1(keep),Y1(keep),Z1(keep),'or')
>
> i get a cylinder of 'keep' points instead of 'keep' point on one side of the plane.

Sounds to me like you just have to reverse the direction of the normal:

keep=(-v)*[X1;Y1;Z1] < v*v';
```
 0

3 Replies
382 Views

Similar Articles

12/5/2013 2:41:12 PM
page loaded in 202677 ms. (0)