How to I surf or 3D mesh 3 different scripts?(Boat)
42 views (last 30 days)
Show older comments
Hi. I want to surf a rowing boat. I have made 3 separate scrips, X=lenght, Y=Width, Z=Hight
The first script describes the XZ-plane, boat as seen form the side, the line that describes the bottom of the boat. It's a staight line form x=0->x=3 then a simple polynom.
The second script describes the gunwale of the boat, as seen from above, the XY-plane. Its 2 curves with different intervals who are symmetric on the x plane. It should rotate between 0 and 180 degrees.
The third script describes the YZ-plane. The boat as seen from behind. (I plotted both curves) its symmetric to the z-plane for all x between 0 and 4.
My question is how do I come from xy, xz, yz -planes to --> surf(X, Y Z). X is from 0 to 4. Z is from 0 to 0.7 and Y from -0.7 to 0.7.
Dont mind the aa, bb, p1 etc that much, its just beizer curves, look at the plot.
if true
%XZ-plane
%Undre kurvan i fören, sidan
x= 3:0.1:4;
z= 0.7*(x-3).^2;
%Beizerkurvans-riktpunker + fix punkt
P0 = [0; 0];
P1 = [1.8; 0.8];
P2 = [4; 0];
PC = [4, 0.7];
%Graf för fören + riktpunkerna
plot(x, z)
hold on
plot(0,0,'r*', 1.8,0.8,'r*',4, 0, 'r*', 4, 0.7, 'r*')
hold on
plot([0 3],[0 0], 'r')
%Övre kurvans ekvation för beizer
%-----------
%
%XY plane
clear all,clf;
%Beizerkurvans-riktpunker + fix punkt
axis equal
t = 0:0.05:1;
pt1 = [0;0];%startpunkt
a=[0, 1];%kurvriktning
b=[1,0];%kurvriktning
a1=0.7;%styrpunktsasvtånd
a2=1.5;%styrpunktsasvtånd
pt4 = [1.8; 0.8];%slutpunkt
pt2=[pt1(1)+a1*a(1);pt1(2)+a1*a(2)];%riktnignspunkt
pt3=[pt4(1)-a2*b(1);pt4(2)-a2*b(2)];%riktingspunkt
pts1 = kron((1-t).^3,pt1) + kron(3*(1-t).^2.*t,pt2) + kron(3*(1-t).*t.^2,pt3) + kron(t.^3,pt4)
xlim([0 4])
hold on
plot(pts1(1,:),pts1(2,:))
p1=[1.8; 0.8]%startpunkt
p4=[4;0];%slutpunkt
aa=[1,0;]%kurvriktning
aa1=1.2;%styrpunktsasvtånd
aa2=0.7;%styrpunktsasvtånd
p2=[p1(1)+aa1*aa(1);p1(2)+aa1*aa(2)];
p3=[3.5;0.866];
pts2 = kron((1-t).^3,p1) + kron(3*(1-t).^2.*t,p2) + kron(3*(1-t).*t.^2,p3) + kron(t.^3,p4);
xlim([0 4])
hold on
plot(pts2(1,:),pts2(2,:))
plot(p2(1), p2(2),'r*', p3(1), p3(2), 'r*')
%
%
%YZ-plane
a= 0.6378
b=0.4252
s1=[0;-1]
s4=[1/2;1/2]
p4=[0;0]
p1=[0.8;0.7]
p2=[p1(1)+a*s1(1);p1(2)+a*s1(2)]
p3=[p4(1)+b*s4(1);p4(2)+b*s4(2)]
pts = kron((1-t).^3,p1) + kron(3*(1-t).^2.*t,p2) + kron(3*(1-t).*t.^2,p3) + kron(t.^3,p4);
xlim([-1 1])
hold on
plot(pts(1,:),pts(2,:))
plot(p4(1),p4(2), 'r*',p1(1),p1(2), 'r*',p2(1),p2(2), 'r*',p3(1),p3(2), 'r*')
%yz plan
a= 0.6378
b=0.4252
s1=[0;-1]
s4=[-1/2;1/2]
p4=[0;0]
p1=[-0.8;0.7]
p2=[p1(1)+a*s1(1);p1(2)+a*s1(2)]
p3=[p4(1)+b*s4(1);p4(2)+b*s4(2)]
pts = kron((1-t).^3,p1) + kron(3*(1-t).^2.*t,p2) + kron(3*(1-t).*t.^2,p3) + kron(t.^3,p4);
xlim([-1 1])
hold on
plot(pts(1,:),pts(2,:))
plot(p4(1),p4(2), 'r*',p1(1),p1(2), 'r*',p2(1),p2(2), 'r*',p3(1),p3(2), 'r*')
end
0 Comments
Answers (1)
Mike Garrity
on 3 Dec 2015
Edited: Mike Garrity
on 3 Dec 2015
You actually don't have enough information to unambiguously define the surface.
Here's the classic illustration of that fact. Let's say we have these three projections:
[xs, ys, zs] = sphere;
grey = [.75 .75 .75];
h(1) = surface(xs,ys,zeros(size(zs))-1.5);
h(2) = surface(zeros(size(xs))+1.5,ys,zs);
h(3) = surface(xs,zeros(size(ys))+1.5,zs);
set(h,'FaceColor',grey,'EdgeColor','none','FaceLighting','none');
axis vis3d
box on
xlim([-1.5 1.5])
ylim([-1.5 1.5])
zlim([-1.5 1.5])
view(3)
What's the surface that's defined by those? It's obviously this sphere, isn't it?
hold on
hs = surf(xs,ys,zs,ones(size(zs)),'EdgeColor','none','FaceLighting','gouraud');
hold off
axis vis3d
camlight
Not really. There are other possibilities. Try this one:
delete(hs)
[y,x,z] = ndgrid(linspace(-1,1,100));
v = max(sqrt(x.^2+y.^2),max(sqrt(y.^2+z.^2), sqrt(z.^2+x.^2)));
isosurface(x,y,z,v,1)
Try rotating that around. You'll see that it lines up with the 3 projections.
So the point of that long winded example is that there are several possible surfaces which can yield the same projections. Going backwards isn't simple. In fact it's a particularly rich field of computer graphics.
The way it is usually done for boats is to have a series of "stations" and "fair" them. You can find a description of that process here, but you don't have enough information to do that. You can probably come up with an approximation that looks good. It's going to involve things like choosing the first partial derivatives along the keel (how "sharp" the bottom of the boat is).
0 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!