http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761
MATLAB Central Newsreader  3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
Feed for thread: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Sat, 07 Jan 2012 09:06:08 +0000
3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863079
Sebastian
3D Plane Intersection: using intersection as <br>
xaxis for 2D plots on each plane<br>
<br>
How Can I do this in simple way?<br>
I tried meshgrid but I can not do this.

Sat, 07 Jan 2012 14:47:11 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863087
ImageAnalyst
On Jan 7, 4:06 am, "Sebastian " <sebastianpszczo...@gmail.com> wrote:<br>
> 3D Plane Intersection: using intersection as<br>
> xaxis for 2D plots on each plane<br>
><br>
> How Can I do this in simple way?<br>
> I tried meshgrid but I can not do this.<br>
<br>
<br>
The intersection of a plane and a solid 3D object (array) is a 2D<br>
planar array. How can a 2D array be used as an xaxis? An xaxis has<br>
to be a 1D array.

Sat, 07 Jan 2012 15:01:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863091
Matt J
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <je91u0$2ld$1@newscl01ah.mathworks.com>...<br>
> 3D Plane Intersection: using intersection as <br>
> xaxis for 2D plots on each plane<br>
> <br>
> How Can I do this in simple way?<br>
> I tried meshgrid but I can not do this.<br>
================<br>
<br>
Not sure exactly what you're doing, but if you have both an xaxis and a yaxis as 3D vectors, you can derive a 2D manifold of meshgrid samples in 3D space as follows:<br>
<br>
[xCoeffs,yCoeffs]=meshgrid(1:Whatever,1:Whatever);<br>
<br>
meshSamples= xCoeffs(:)*xaxis(:).' + yCoeffs(:)*yaxis(:).';<br>
<br>
The rows of meshSamples are each the 3D coordinate of a point on the mesh.

Sat, 07 Jan 2012 15:09:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863093
Matt J
"Matt J" wrote in message <je9mnk$112$1@newscl01ah.mathworks.com>...<br>
><br>
> Not sure exactly what you're doing, but if you have both an xaxis and a yaxis as 3D vectors, you can derive a 2D manifold of meshgrid samples in 3D space as follows:<br>
> <br>
> [xCoeffs,yCoeffs]=meshgrid(1:Whatever,1:Whatever);<br>
> <br>
> meshSamples= xCoeffs(:)*xaxis(:).' + yCoeffs(:)*yaxis(:).';<br>
> <br>
> The rows of meshSamples are each the 3D coordinate of a point on the mesh.<br>
=====================<br>
<br>
<br>
Oh, and of course if the plane doesn't pass through the origin, you will need to add a 3D offset vector to all the rows of meshSamples, e.g., by doing<br>
<br>
meshSamples= bsxfun(@plus, meshSamples,offset(:).');

Sat, 07 Jan 2012 19:19:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863112
Roger Stafford
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <je91u0$2ld$1@newscl01ah.mathworks.com>...<br>
> 3D Plane Intersection: using intersection as <br>
> xaxis for 2D plots on each plane<br>
> <br>
> How Can I do this in simple way?<br>
> I tried meshgrid but I can not do this.<br>
         <br>
Let's see if I can successfully interpret what you are saying, Sebastian. You have somehow defined two intersecting planes in threedimensional space. Probably you have a set of points identified on each plane. You wish to plot each of these sets in a twodimensional plot on each of the planes using as a new xaxis the line of intersection of the planes. Is that what you are asking?<br>
<br>
Of course the immediate question that occurs is where the new origin is to be located along the line of intersection. A natural choice would be the orthogonal projection of the original 3D origin onto that line. There is also the question of which of two directions should the two respective yaxes point  that is, which side of each of the planes should our points of view be from in the 2D plots?<br>
<br>
There is also the possibility that you actually have only one set of 3D points and two planes defined, and that you want to orthogonally project those points onto each of the planes and then prepare a 2D plot of those projected points as they would appear with new x and y axes within the respective planes using the intersection line as xaxis.<br>
<br>
Before we go any further in this problem it would be best if you would tell in much greater detail just what it is you are asking here. That is important in avoiding a waste of other people's time working out explanations that are not pertinent to your needs.<br>
<br>
Roger Stafford

Sat, 07 Jan 2012 19:45:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863114
Sebastian
"Roger Stafford" wrote in message <jea5rc$di8$1@newscl01ah.mathworks.com>...<br>
> "Sebastian " <sebastianpszczolka@gmail.com> wrote in message <je91u0$2ld$1@newscl01ah.mathworks.com>...<br>
> > 3D Plane Intersection: using intersection as <br>
> > xaxis for 2D plots on each plane<br>
> > <br>
> > How Can I do this in simple way?<br>
> > I tried meshgrid but I can not do this.<br>
>          <br>
> Let's see if I can successfully interpret what you are saying, Sebastian. You have somehow defined two intersecting planes in threedimensional space. Probably you have a set of points identified on each plane. You wish to plot each of these sets in a twodimensional plot on each of the planes using as a new xaxis the line of intersection of the planes. Is that what you are asking?<br>
> <br>
> Of course the immediate question that occurs is where the new origin is to be located along the line of intersection. A natural choice would be the orthogonal projection of the original 3D origin onto that line. There is also the question of which of two directions should the two respective yaxes point  that is, which side of each of the planes should our points of view be from in the 2D plots?<br>
> <br>
> There is also the possibility that you actually have only one set of 3D points and two planes defined, and that you want to orthogonally project those points onto each of the planes and then prepare a 2D plot of those projected points as they would appear with new x and y axes within the respective planes using the intersection line as xaxis.<br>
> <br>
> Before we go any further in this problem it would be best if you would tell in much greater detail just what it is you are asking here. That is important in avoiding a waste of other people's time working out explanations that are not pertinent to your needs.<br>
> <br>
> Roger Stafford<br>
<br>
<br>
You are absolutley right I will show you what I have already done:<br>
There is fucntion which calculate point for 2 planes from normal vector and point on planes.<br>
<code><br>
function [x1,y1,z1,x2,y2,z2]=calculateplanes(obj) <br>
point = [obj.A1(1),obj.A1(2),obj.A1(3)]; <br>
normal = [obj.N1(1),obj.N1(2),obj.N1(3)]; <br>
<br>
%# a plane is a*x+b*y+c*z+d=0 <br>
%# [a,b,c] is the normal. Thus, we have to calculate <br>
%# d and we're set <br>
d = point*normal'; %'# dot product for less typing <br>
<br>
%# create x,y <br>
[xx,yy]=ndgrid(1:10,1:10); <br>
<br>
%# calculate corresponding z <br>
z1 = (normal(1)*xx  normal(2)*yy  d)/normal(3); <br>
x1=xx; <br>
y1=yy; <br>
<br>
point = [obj.A2(1),obj.A2(2),obj.A2(3)]; <br>
normal = [obj.N2(1),obj.N2(2),obj.N2(3)]; <br>
<br>
%# a plane is a*x+b*y+c*z+d=0 <br>
%# [a,b,c] is the normal. Thus, we have to calculate <br>
%# d and we're set <br>
d = point*normal'; %'# dot product for less typing <br>
<br>
%# create x,y <br>
[xx,yy]=ndgrid(1:10,1:10); <br>
<br>
%# calculate corresponding z <br>
z2 = (normal(1)*xx  normal(2)*yy  d)/normal(3); <br>
x2=xx; <br>
y2=yy; <br>
<br>
end <br>
</code><br>
<br>
There is function which calculate intersection beetwen 2 planes and it gives me point on straight and direction vector but I do not know how to draw any function on each of plane. Can You help me with this and check my code beacause i do not know if it is the best way to achive ma object. I draw planes using surf(x1,y1,z1) hold on surf(x2,y2,z2) <br>
function [P,N,check]=plane_intersect(obj) <br>
P=[0 0 0]; <br>
N=cross(obj.N1,obj.N2); <br>
<br>
if norm(N) < 10^7 % Plane 1 and Plane 2 are near parallel <br>
V=obj.A1obj.A2; <br>
if (dot(obj.N1,V) == 0) <br>
check=1; % Plane 1 and Plane 2 coincide <br>
return <br>
else <br>
check=0; %Plane 1 and Plane 2 are disjoint <br>
return <br>
end <br>
end <br>
check=2; <br>
maxc=find(abs(N)==max(abs(N))); <br>
d1 = dot(obj.N1,obj.A1); %the constants in the Plane 1 equations <br>
d2 = dot(obj.N2, obj.A2); %the constants in the Plane 2 equations <br>
switch maxc <br>
case 1 % intersect with x=0 <br>
P(1)= 0; <br>
P(2) = (d2*obj.N1(3)  d1*obj.N2(3))/ N(1); <br>
P(3) = (d1*obj.N2(2)  d2*obj.N1(2))/ N(1); <br>
case 2 %intersect with y=0 <br>
P(1) = (d1*obj.N2(3)  d2*obj.N1(3))/ N(2); <br>
P(2) = 0; <br>
P(3) = (d2*obj.N1(1)  d1*obj.N2(1))/ N(2); <br>
case 3 %intersect with z=0 <br>
P(1) = (d2*obj.N1(2)  d1*obj.N2(2))/ N(3); <br>
P(2) = (d1*obj.N2(1)  d2*obj.N1(1))/ N(3); <br>
P(3) = 0; <br>
end <br>
end <br>
<br>
Thank you a lot

Sat, 07 Jan 2012 19:49:09 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863115
Sebastian
"Roger Stafford" wrote in message <jea5rc$di8$1@newscl01ah.mathworks.com>...<br>
> "Sebastian " <sebastianpszczolka@gmail.com> wrote in message <je91u0$2ld$1@newscl01ah.mathworks.com>...<br>
> > 3D Plane Intersection: using intersection as <br>
> > xaxis for 2D plots on each plane<br>
> > <br>
> > How Can I do this in simple way?<br>
> > I tried meshgrid but I can not do this.<br>
>          <br>
> Let's see if I can successfully interpret what you are saying, Sebastian. You have somehow defined two intersecting planes in threedimensional space. Probably you have a set of points identified on each plane. You wish to plot each of these sets in a twodimensional plot on each of the planes using as a new xaxis the line of intersection of the planes. Is that what you are asking?<br>
> <br>
> Of course the immediate question that occurs is where the new origin is to be located along the line of intersection. A natural choice would be the orthogonal projection of the original 3D origin onto that line. There is also the question of which of two directions should the two respective yaxes point  that is, which side of each of the planes should our points of view be from in the 2D plots?<br>
> <br>
> There is also the possibility that you actually have only one set of 3D points and two planes defined, and that you want to orthogonally project those points onto each of the planes and then prepare a 2D plot of those projected points as they would appear with new x and y axes within the respective planes using the intersection line as xaxis.<br>
> <br>
> Before we go any further in this problem it would be best if you would tell in much greater detail just what it is you are asking here. That is important in avoiding a waste of other people's time working out explanations that are not pertinent to your needs.<br>
> <br>
> Roger Stafford<br>
<br>
<br>
You are absolutley right I will show you what I have already done:<br>
There is fucntion which calculate point for 2 planes from normal vector and point on planes.<br>
<code><br>
function [x1,y1,z1,x2,y2,z2]=calculateplanes(obj) <br>
point = [obj.A1(1),obj.A1(2),obj.A1(3)]; <br>
normal = [obj.N1(1),obj.N1(2),obj.N1(3)]; <br>
<br>
%# a plane is a*x+b*y+c*z+d=0 <br>
%# [a,b,c] is the normal. Thus, we have to calculate <br>
%# d and we're set <br>
d = point*normal'; %'# dot product for less typing <br>
<br>
%# create x,y <br>
[xx,yy]=ndgrid(1:10,1:10); <br>
<br>
%# calculate corresponding z <br>
z1 = (normal(1)*xx  normal(2)*yy  d)/normal(3); <br>
x1=xx; <br>
y1=yy; <br>
<br>
point = [obj.A2(1),obj.A2(2),obj.A2(3)]; <br>
normal = [obj.N2(1),obj.N2(2),obj.N2(3)]; <br>
<br>
%# a plane is a*x+b*y+c*z+d=0 <br>
%# [a,b,c] is the normal. Thus, we have to calculate <br>
%# d and we're set <br>
d = point*normal'; %'# dot product for less typing <br>
<br>
%# create x,y <br>
[xx,yy]=ndgrid(1:10,1:10); <br>
<br>
%# calculate corresponding z <br>
z2 = (normal(1)*xx  normal(2)*yy  d)/normal(3); <br>
x2=xx; <br>
y2=yy; <br>
<br>
end <br>
</code><br>
<br>
There is function which calculate intersection beetwen 2 planes and it gives me point on straight and direction vector but I do not know how to draw any function on each of plane. Can You help me with this and check my code beacause i do not know if it is the best way to achive ma object. I draw planes using surf(x1,y1,z1) hold on surf(x2,y2,z2) <br>
function [P,N,check]=plane_intersect(obj) <br>
P=[0 0 0]; <br>
N=cross(obj.N1,obj.N2); <br>
<br>
if norm(N) < 10^7 % Plane 1 and Plane 2 are near parallel <br>
V=obj.A1obj.A2; <br>
if (dot(obj.N1,V) == 0) <br>
check=1; % Plane 1 and Plane 2 coincide <br>
return <br>
else <br>
check=0; %Plane 1 and Plane 2 are disjoint <br>
return <br>
end <br>
end <br>
check=2; <br>
maxc=find(abs(N)==max(abs(N))); <br>
d1 = dot(obj.N1,obj.A1); %the constants in the Plane 1 equations <br>
d2 = dot(obj.N2, obj.A2); %the constants in the Plane 2 equations <br>
switch maxc <br>
case 1 % intersect with x=0 <br>
P(1)= 0; <br>
P(2) = (d2*obj.N1(3)  d1*obj.N2(3))/ N(1); <br>
P(3) = (d1*obj.N2(2)  d2*obj.N1(2))/ N(1); <br>
case 2 %intersect with y=0 <br>
P(1) = (d1*obj.N2(3)  d2*obj.N1(3))/ N(2); <br>
P(2) = 0; <br>
P(3) = (d2*obj.N1(1)  d1*obj.N2(1))/ N(2); <br>
case 3 %intersect with z=0 <br>
P(1) = (d2*obj.N1(2)  d1*obj.N2(2))/ N(3); <br>
P(2) = (d1*obj.N2(1)  d2*obj.N1(1))/ N(3); <br>
P(3) = 0; <br>
end <br>
end <br>
<br>
Thank you a lot

Sat, 07 Jan 2012 22:08:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863120
Roger Stafford
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jea7jl$ifo$1@newscl01ah.mathworks.com>...<br>
> You are absolutley right I will show you what I have already done: ......<br>
          <br>
You've shown us code for determining a mesh of points in 3D projected vertically from the xy plane into each of the planes and how you find those planes' line of intersection, but you haven't answered the questions as to 1) where on this line of intersection the new 2D origin is to be located, 2) in which direction along this line should be the positive xaxis, and 3) in which of two possible directions on each plane are to be the new positive yaxes. No doubt you can devise some scheme in terms of the cross product of the normals to the planes. You need to know all of this to exhibit these points in 2D plots.<br>
<br>
Instead of starting with an entire mesh of points on the original 3D xy plane, why don't you just ask about determining how a single point (x,y,z) in 3D known to be on one of the planes is transformed into (x,y) coordinates on that plane in new 2D coordinates, (given the two planes and the answers to 1, 2, and 3 above?)<br>
<br>
Roger Stafford

Sat, 07 Jan 2012 22:39:09 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863122
Matt J
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jea7jl$ifo$1@newscl01ah.mathworks.com>...<br>
><br>
> There is function which calculate intersection beetwen 2 planes and it gives me point on straight and direction vector but I do not know how to draw any function on each of plane. <br>
===================<br>
<br>
You need to clarify what it means to "draw any function on each of plane". If you mean you want an image (i.e. a 2D function) displayed on the surface of a plane in 3D, then maybe this is what you want:<br>
<br>
<a href="http://www.mathworks.com/matlabcentral/fileexchange/28581imsurf3dimages">http://www.mathworks.com/matlabcentral/fileexchange/28581imsurf3dimages</a>

Sun, 08 Jan 2012 09:13:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863139
Sebastian
It will be OK if firstly i can draw cosinus fucntion on plane definied by me.<br>
How to draw plot on planes defineid by me and drew by surf

Sun, 08 Jan 2012 11:14:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863143
Sebastian
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jebmn4$1g1$1@newscl01ah.mathworks.com>...<br>
> It will be OK if firstly i can draw cosinus fucntion on plane definied by me.<br>
> How to draw plot on planes defineid by me and drew by surf<br>
I want to plot any function on planes definied like normal vector and point.<br>
How Can I do this because it will be a little step to my object.<br>
I tried using <br>
tri1 = delaunay(x1,y1);<br>
plot(x1,y1,'Color','red');<br>
tri2 = delaunay(x,y);<br>
hold on<br>
plot(x,y,'Color','green');<br>
<br>
<br>
trisurf(tri1, x1, y1, z1,'FaceColor','blue');<br>
trisurf(tri1, x, y, z,'FaceColor','blue');<br>
<br>
but it doesn't work.<br>
Thank You

Sun, 08 Jan 2012 14:01:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863153
Matt J
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jebmn4$1g1$1@newscl01ah.mathworks.com>...<br>
> It will be OK if firstly i can draw cosinus fucntion on plane definied by me.<br>
> How to draw plot on planes defineid by me and drew by surf<br>
===============<br>
<br>
It's still a bit unclear to me why why you're turning to surface plotting commands when the thing you want to create (a plot of the cosine function) is a 1D space curve, not a 2D surface.<br>
<br>
What about the following? It is a cosine curve occupying the plane spanned by xaxis and yaxis. How is this different from what you want? Note that you could also use PLOT3 instead of EZPLOT3.<br>
<br>
<br>
xaxis=[1 1 0]/sqrt(2);<br>
yaxis=[0 0 1];<br>
<br>
funx=@(t) t*xaxis(1)+cos(t)*yaxis(1);<br>
funy=@(t) t*xaxis(2)+cos(t)*yaxis(2);<br>
funz=@(t) t*xaxis(3)+cos(t)*yaxis(3);<br>
<br>
ezplot3(funx,funy,funz,[4*pi, 4*pi]); title ''

Sun, 08 Jan 2012 19:01:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863159
Sebastian
Thank for answer,<br>
My task is from normal vector and point i should plot one plane. From another normal vector and point i should plot another plane on their intersection is my new xaxis and i should plot on one plane cosinus and on another sinus. I have plotted two intersection plane and I have equation for straight its direction vecotr and point but I do not know how to draw any function eg. sinus on this planes. Can someone help me?<br>
Thank You

Sun, 08 Jan 2012 22:54:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863164
Roger Stafford
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jecp5k$8ft$1@newscl01ah.mathworks.com>...<br>
> My task is from normal vector and point i should plot one plane. From another normal vector and point i should plot another plane on their intersection is my new xaxis and i should plot on one plane cosinus and on another sinus. I have plotted two intersection plane and I have equation for straight its direction vecotr and point but I do not know how to draw any function eg. sinus on this planes. Can someone help me?<br>
> Thank You<br>
         <br>
As nearly as I can understand your request, your problem can be divided into three basic tasks. First, you are given two point/normal pairs which each define a plane in three dimensions, and you must determine some particular point on their line of intersection to be a new origin. As you may recall, I suggested choosing it as the orthogonal projection of the old origin onto that intersection line.<br>
<br>
Second, you must determine two new sets of axes using this new origin in which the xaxis is along the planes' intersection for both new coordinates, the zaxes are along the respective positive normal directions, and the yaxes form the usual righthand systems lying within the planes and orthogonal to the intersection line.<br>
<br>
Third, you apparently have the need to transform from new coordinates to old, and possibly old coordinates to new ones, for each of the two planes' systems.<br>
<br>
For the first, call (as you did) the two normals N1 and N2, and the two corresponding points lying somewhere in the planes, A1 and A2. In the absence of any other criterion, let P0 be, as suggested, the orthogonal projection of the origin onto the planes' intersection line. Then we must have the three equations for P0 = (x0,y0,z0):<br>
<br>
dot(N1,P0) = dot(N1,A1)<br>
dot(N2,P0) = dot(N2,A2)<br>
dot(cross(N1,N2),P0) = 0<br>
<br>
which represent three equations in the three unknowns, x0, y0, and z0. As can be demonstrated, the solution is:<br>
<br>
P0 = (cross(N2,cross(N1,N2))*dot(N1,A1)cross(N1,cross(N1,N2))*dot(N2,A2)) / ...<br>
dot(cross(N1,N2),cross(N1,N2));<br>
<br>
(Note that this is valid whether N1 and N2 have been normalized or not.)<br>
<br>
That establishes a new origin for both new coordinate systems as a point on the planes' line of intersection, namely the closest point to the old origin.<br>
<br>
For the second task we can choose cross(N1,N2) to point in the direction of the new positive xaxis common to both new coordinate systems. Define the unit vector<br>
<br>
u1 = cross(N1,N2)/norm(cross(N1,N2));<br>
<br>
which will be a unit vector along the new xaxis. Then define a unit vector w1, orthogonal to it as:<br>
<br>
w1 = N1/norm(N1);<br>
<br>
This will be the new zaxis for the first plane. It points along the normal to the plane. Finally define<br>
<br>
v1 = cross(w1,u1);<br>
<br>
and this will be the new yaxis of the plane lying in that plane. The triple u1,v1,w1 constitutes a righthand system of orthogonal unit vectors oriented in relation to the first plane.<br>
<br>
This can be repeated with the second plane to form u2, v2, and w2 where u1 and u2 are the same, and we again have an orthonormal set of vectors for the second plane.<br>
<br>
For the third task using the first plane we want to establish a transformation between the original set of coordinates and a new set relative to u1,v1,w1. Let Q1 = (X1,Y1,Z1) be coordinates relative to the (u1,v1,w1) set of an arbitrary point P = (x,y,z) (relative to the original coordinate system.) We must have the equality<br>
<br>
P = u1*X1+v1*Y1+w1*Z1 + P0<br>
<br>
If we agree to make u1, v1, and w1 row vectors and P and Q column vectors, we can write the matlab expression<br>
<br>
T1 = [u1;v1;w1];<br>
P = bsxfun(@plus,T1*Q1,P0);<br>
<br>
The 'bsxfun' function is used here to make this valid even if P and Q1 are 3 by n matrices for n points in which each column has the three coordinates of the corresponding point.<br>
<br>
To transform in the opposite direction from P to Q1, it is simply<br>
<br>
Q1 = T1'*bsxfun(@minus,P,P0);<br>
<br>
That is true because T1 is inherently a unitary matrix and its inverse is the same as its (conjugate) transpose.<br>
<br>
Similar statements can be made for a 3 by 3 matrix T2 with respect to the second plane's coordinate system.<br>
<br>
(It should be noted that all this is analogous to the problem of rotating and translating solid bodies within a fixed coordinate system. The T matrices become the rotation matrices.)<br>
<br>
Now with all these methods you have the means to transform twodimensional plots made for X1,Y1,Z1 coordinates, assuming Z1 is a constant zero, and transforming them into the original x,y,z coordinates which you can plot using 'plot3' where these points will all show up as lying in the given plane. If you do the same with X2,Y2,Z2 coordinate sets, both sets can be displayed on the 'plot3' plot together and you will observe the points lying in two planes there. As pointed out above, you can use entire 3 by n matrices to make transformations of plots in a single line for these transformations.<br>
<br>
Roger Stafford

Mon, 09 Jan 2012 07:27:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863194
Sebastian
"Roger Stafford" wrote in message <jed6qg$grf$1@newscl01ah.mathworks.com>...<br>
> "Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jecp5k$8ft$1@newscl01ah.mathworks.com>...<br>
> > My task is from normal vector and point i should plot one plane. From another normal vector and point i should plot another plane on their intersection is my new xaxis and i should plot on one plane cosinus and on another sinus. I have plotted two intersection plane and I have equation for straight its direction vecotr and point but I do not know how to draw any function eg. sinus on this planes. Can someone help me?<br>
> > Thank You<br>
>          <br>
> As nearly as I can understand your request, your problem can be divided into three basic tasks. First, you are given two point/normal pairs which each define a plane in three dimensions, and you must determine some particular point on their line of intersection to be a new origin. As you may recall, I suggested choosing it as the orthogonal projection of the old origin onto that intersection line.<br>
> <br>
> Second, you must determine two new sets of axes using this new origin in which the xaxis is along the planes' intersection for both new coordinates, the zaxes are along the respective positive normal directions, and the yaxes form the usual righthand systems lying within the planes and orthogonal to the intersection line.<br>
> <br>
> Third, you apparently have the need to transform from new coordinates to old, and possibly old coordinates to new ones, for each of the two planes' systems.<br>
> <br>
> For the first, call (as you did) the two normals N1 and N2, and the two corresponding points lying somewhere in the planes, A1 and A2. In the absence of any other criterion, let P0 be, as suggested, the orthogonal projection of the origin onto the planes' intersection line. Then we must have the three equations for P0 = (x0,y0,z0):<br>
> <br>
> dot(N1,P0) = dot(N1,A1)<br>
> dot(N2,P0) = dot(N2,A2)<br>
> dot(cross(N1,N2),P0) = 0<br>
> <br>
> which represent three equations in the three unknowns, x0, y0, and z0. As can be demonstrated, the solution is:<br>
> <br>
> P0 = (cross(N2,cross(N1,N2))*dot(N1,A1)cross(N1,cross(N1,N2))*dot(N2,A2)) / ...<br>
> dot(cross(N1,N2),cross(N1,N2));<br>
> <br>
> (Note that this is valid whether N1 and N2 have been normalized or not.)<br>
> <br>
> That establishes a new origin for both new coordinate systems as a point on the planes' line of intersection, namely the closest point to the old origin.<br>
> <br>
> For the second task we can choose cross(N1,N2) to point in the direction of the new positive xaxis common to both new coordinate systems. Define the unit vector<br>
> <br>
> u1 = cross(N1,N2)/norm(cross(N1,N2));<br>
> <br>
> which will be a unit vector along the new xaxis. Then define a unit vector w1, orthogonal to it as:<br>
> <br>
> w1 = N1/norm(N1);<br>
> <br>
> This will be the new zaxis for the first plane. It points along the normal to the plane. Finally define<br>
> <br>
> v1 = cross(w1,u1);<br>
> <br>
> and this will be the new yaxis of the plane lying in that plane. The triple u1,v1,w1 constitutes a righthand system of orthogonal unit vectors oriented in relation to the first plane.<br>
> <br>
> This can be repeated with the second plane to form u2, v2, and w2 where u1 and u2 are the same, and we again have an orthonormal set of vectors for the second plane.<br>
> <br>
> For the third task using the first plane we want to establish a transformation between the original set of coordinates and a new set relative to u1,v1,w1. Let Q1 = (X1,Y1,Z1) be coordinates relative to the (u1,v1,w1) set of an arbitrary point P = (x,y,z) (relative to the original coordinate system.) We must have the equality<br>
> <br>
> P = u1*X1+v1*Y1+w1*Z1 + P0<br>
> <br>
> If we agree to make u1, v1, and w1 row vectors and P and Q column vectors, we can write the matlab expression<br>
> <br>
> T1 = [u1;v1;w1];<br>
> P = bsxfun(@plus,T1*Q1,P0);<br>
> <br>
> The 'bsxfun' function is used here to make this valid even if P and Q1 are 3 by n matrices for n points in which each column has the three coordinates of the corresponding point.<br>
> <br>
> To transform in the opposite direction from P to Q1, it is simply<br>
> <br>
> Q1 = T1'*bsxfun(@minus,P,P0);<br>
> <br>
> That is true because T1 is inherently a unitary matrix and its inverse is the same as its (conjugate) transpose.<br>
> <br>
> Similar statements can be made for a 3 by 3 matrix T2 with respect to the second plane's coordinate system.<br>
> <br>
> (It should be noted that all this is analogous to the problem of rotating and translating solid bodies within a fixed coordinate system. The T matrices become the rotation matrices.)<br>
> <br>
> Now with all these methods you have the means to transform twodimensional plots made for X1,Y1,Z1 coordinates, assuming Z1 is a constant zero, and transforming them into the original x,y,z coordinates which you can plot using 'plot3' where these points will all show up as lying in the given plane. If you do the same with X2,Y2,Z2 coordinate sets, both sets can be displayed on the 'plot3' plot together and you will observe the points lying in two planes there. As pointed out above, you can use entire 3 by n matrices to make transformations of plots in a single line for these transformations.<br>
> <br>
> Roger Stafford<br>
<br>
<br>
Thank you a lot. It is very helpful to understand how to do this.<br>
I am new with that problem Can you give me simple example how to use this code because I tried did this in my way and I failed. <br>
Thank You a lot.

Mon, 09 Jan 2012 12:21:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863217
Matt J
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jecp5k$8ft$1@newscl01ah.mathworks.com>...<br>
> Thank for answer,<br>
> My task is from normal vector and point i should plot one plane. From another normal vector and point i should plot another plane on their intersection is my new xaxis and i should plot on one plane cosinus and on another sinus. I have plotted two intersection plane and I have equation for straight its direction vecotr and point but I do not know how to draw any function eg. sinus on this planes. Can someone help me?<br>
====================<br>
<br>
But I gave you an example of how to do exactly that in my last post...

Mon, 09 Jan 2012 12:44:09 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863221
Sebastian
"Matt J" wrote in message <jeem3k$18f$1@newscl01ah.mathworks.com>...<br>
> "Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jecp5k$8ft$1@newscl01ah.mathworks.com>...<br>
> > Thank for answer,<br>
> > My task is from normal vector and point i should plot one plane. From another normal vector and point i should plot another plane on their intersection is my new xaxis and i should plot on one plane cosinus and on another sinus. I have plotted two intersection plane and I have equation for straight its direction vecotr and point but I do not know how to draw any function eg. sinus on this planes. Can someone help me?<br>
> ====================<br>
> <br>
> But I gave you an example of how to do exactly that in my last post...<br>
<br>
Thank you very much but Can You explain me that statment because I think it is not complete:<br>
P0 = (cross(N2,cross(N1,N2))*dot(N1,A1)cross(N1,cross(N1,N2))*dot(N2,A2)) / ...<br>
dot(cross(N1,N2),cross(N1,N2)<br>
<br>
Thank a lot

Mon, 09 Jan 2012 14:43:08 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863237
Matt J
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jeenep$53k$1@newscl01ah.mathworks.com>...<br>
><br>
> > <br>
> > But I gave you an example of how to do exactly that in my last post...<br>
> <br>
> Thank you very much but Can You explain me that statment because I think it is not complete:<br>
> P0 = (cross(N2,cross(N1,N2))*dot(N1,A1)cross(N1,cross(N1,N2))*dot(N2,A2)) / ...<br>
> dot(cross(N1,N2),cross(N1,N2)<br>
===============<br>
<br>
<br>
I never made a statement like that. Roger did.

Mon, 09 Jan 2012 18:19:09 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863252
Roger Stafford
"Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jee4sc$bnd$1@newscl01ah.mathworks.com>...<br>
> Thank you a lot. It is very helpful to understand how to do this.<br>
> I am new with that problem Can you give me simple example how to use this code because I tried did this in my way and I failed. <br>
> Thank You a lot.<br>
        <br>
Sebastian, I have a correction to make in yesterday's explanation. Where I said "make u1, v1, and w1 row vectors" and "T1=[u1;v1;w1];" I should have said:<br>
<br>
"If we agree to make u1, v1, w1, P, and Q all column vectors, we can write the matlab expression<br>
<br>
T1 = [u1,v1,w1];"<br>
<br>
My previous T1 was the inverse of what it should have been. My apologies.<br>
<br>
As to your question about the formula for P0, what is the problem you have with it? I did test it carefully and it is correct. It consists of a numerator which is the difference between two vectors, and a scalar in the denominator. In matlab it would be more efficient to write it like this:<br>
<br>
t = cross(N1,N2);<br>
P0 = (cross(N2,t)*dot(N1,A1)cross(N1,t)*dot(N2,A2))/dot(t,t);<br>
<br>
It is easy to see that this satisfies the three required equations.<br>
<br>
You have asked for an example of this. Suppose you wish to exhibit, three dimensionally, a plot of Y1 = sin(X1) for 0 <= X1 <= 2*pi on plane #1. I'll generate two planes randomly.<br>
<br>
N1 = randn(3,1); A1 = randn(3,1); % The first plane<br>
N2 = randn(3,1); A2 = randn(3,1); % The second plane<br>
n = 200;<br>
X1 = linspace(0,2*pi,n);<br>
Y1 = sin(X1); % The sine function on plane 1<br>
Z1 = zeros(1,n); % Place it on the plane<br>
Q1 = [X1;Y1;Z1];<br>
<br>
t = cross(N1,N2);<br>
P0 = (cross(N2,t)*dot(N1,A1)cross(N1,t)*dot(N2,A2))/dot(t,t);<br>
u1 = t/norm(t); % Get three orthogonal unit vectors<br>
w1 = N1/norm(N1);<br>
v1 = cross(w1,u1);<br>
T1 = [u1,v1,w1]; % Prepare the transformation matrix<br>
P = bsxfun(@plus,T1*Q1,P0); % Sine curve in three dimensions<br>
plot3(P(1,:),P(2,:),P(3,:)) % Plot it<br>
<br>
(Note that instead of troubling to generate the zeros in Z1, you could just as well eliminate the third column of T1 and the third row of Q1.)<br>
<br>
Roger Stafford

Mon, 09 Jan 2012 20:39:09 +0000
Re: 3D Plane Intersection: using intersection as xaxis for 2D plots on each plane
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315761#863272
Sebastian
"Roger Stafford" wrote in message <jefb2t$g55$1@newscl01ah.mathworks.com>...<br>
> "Sebastian " <sebastianpszczolka@gmail.com> wrote in message <jee4sc$bnd$1@newscl01ah.mathworks.com>...<br>
> > Thank you a lot. It is very helpful to understand how to do this.<br>
> > I am new with that problem Can you give me simple example how to use this code because I tried did this in my way and I failed. <br>
> > Thank You a lot.<br>
>         <br>
> Sebastian, I have a correction to make in yesterday's explanation. Where I said "make u1, v1, and w1 row vectors" and "T1=[u1;v1;w1];" I should have said:<br>
> <br>
> "If we agree to make u1, v1, w1, P, and Q all column vectors, we can write the matlab expression<br>
> <br>
> T1 = [u1,v1,w1];"<br>
> <br>
> My previous T1 was the inverse of what it should have been. My apologies.<br>
> <br>
> As to your question about the formula for P0, what is the problem you have with it? I did test it carefully and it is correct. It consists of a numerator which is the difference between two vectors, and a scalar in the denominator. In matlab it would be more efficient to write it like this:<br>
> <br>
> t = cross(N1,N2);<br>
> P0 = (cross(N2,t)*dot(N1,A1)cross(N1,t)*dot(N2,A2))/dot(t,t);<br>
> <br>
> It is easy to see that this satisfies the three required equations.<br>
> <br>
> You have asked for an example of this. Suppose you wish to exhibit, three dimensionally, a plot of Y1 = sin(X1) for 0 <= X1 <= 2*pi on plane #1. I'll generate two planes randomly.<br>
> <br>
> N1 = randn(3,1); A1 = randn(3,1); % The first plane<br>
> N2 = randn(3,1); A2 = randn(3,1); % The second plane<br>
> n = 200;<br>
> X1 = linspace(0,2*pi,n);<br>
> Y1 = sin(X1); % The sine function on plane 1<br>
> Z1 = zeros(1,n); % Place it on the plane<br>
> Q1 = [X1;Y1;Z1];<br>
> <br>
> t = cross(N1,N2);<br>
> P0 = (cross(N2,t)*dot(N1,A1)cross(N1,t)*dot(N2,A2))/dot(t,t);<br>
> u1 = t/norm(t); % Get three orthogonal unit vectors<br>
> w1 = N1/norm(N1);<br>
> v1 = cross(w1,u1);<br>
> T1 = [u1,v1,w1]; % Prepare the transformation matrix<br>
> P = bsxfun(@plus,T1*Q1,P0); % Sine curve in three dimensions<br>
> plot3(P(1,:),P(2,:),P(3,:)) % Plot it<br>
> <br>
> (Note that instead of troubling to generate the zeros in Z1, you could just as well eliminate the third column of T1 and the third row of Q1.)<br>
> <br>
> Roger Stafford<br>
<br>
<br>
Thank you it is great