Matlab实验之画茶壶

matlab实验之画茶壶

1.程序如下

%% Displaying Complex Three-Dimensional Objects
% This example shows how to create and display a complex three dimensional
% object and control its appearance.

%   Copyright 2014 The MathWorks, Inc.

%% Get Geometry of Object
% This example uses a graphics object called the Newell teapot.  The
% vertex, face, and color index data for the teapot are calculated by the
% |teapotData| function. Since the teapot is a complex geometric shape,
% there are a large number of vertices (4608) and faces (3872) returned by
% the function.

[verts, faces, cindex] = teapotGeometry;

%% Create Teapot Patch Object
% Using the geometry data, draw the teapot using the |patch| command.  The
% |patch| command creates a patch object.

figure
p = patch('Faces',faces,'Vertices',verts,'FaceVertexCData',cindex,'FaceColor','interp')
%%
% Use the |view| command to change the orientation of the object.

view(-151,30)     % change the orientation
axis equal off    % make the axes equal and invisible

%% Adjust Transparency
% Make the object transparent using the |FaceAlpha| property of the patch
% object.

p.FaceAlpha = 0.3;   % make the object semi-transparent

%% 
% If the |FaceColor| property is set to 'none', then the object appears as
% a wire frame diagram.

p.FaceColor = 'none';    % turn off the colors

%% Change Colormap
% Change the colors for the object using the |colormap| function.

p.FaceAlpha = 1;           % remove the transparency
p.FaceColor = 'interp';    % set the face colors to be interpolated
p.LineStyle = 'none';      % remove the lines
colormap(copper)           % change the colormap

%% Light the Object
% Add a light to make the object appear more realistic.

l = light('Position',[-0.4 0.2 0.9],'Style','infinite')
lighting gouraud

%%
% These properties of the patch object affect the strength of the light and
% the refective properties of the object:
%
% * |AmbientStrength| - controls the strength of ambient light
% * |DiffuseStrength| - controls the strength of diffuse light
% * |SpecularStrength| - controls the strength of reflected light
% * |SpecularExponent| - controls the harshness of reflected light
% * |SpecularColorReflectance| - controls how refected color is calculated.
%
% You can set these properties individually. To set these properties to a
% predetermined set of values that approximate the appearance of metal,
% shiny, or dull material, use the |material| command.

material shiny

%%
% Adjust the position of the light using its |Position| property.  The
% position is in _x_, _y_, _z_ coordinates.

l.Position = [-0.1 0.6 0.8]

2.效果如下图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

珞瑜·

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值