2D graphics and D graphics in Matlab
• 2D graphics
- plot
- axes & labels
- multiple plots
- special plots
• 3D graphics
- line
- surface
• Polynomials
• Interpolation
& splines
• Optimisation
• Integration,
differentiation & ODEs
• Data-structures
• Object Oriented
• GUIs
• Toolboxes
27 3D MAPS IN MATLAB, A CASE STUDY
• To date we have
concentrated on the Matlab programming language & its constructs
• Today’s lecture
looks at employing the various language features we have seen
- solve a
semi-artificial problem
- larger in scale
than those seen in class or assignments
- a suite of related functions for
the creation and manipulation of pseudo-realistic 3D maps
References: Matlab
Competency Exercises
Matlab
Lectures
27.1 Problem Specification
• DSTO’s Synthetic
Environment Research Facility (SERF) is looking for some 3D terrain
generation suitable for their various wargame simulations.
|
• The program(s):
- should generate 3D
digital terrain suitable for incorporation into their CAEN (Close Action
ENvironment) system
- should produce the
data as a grid of heights at equi-spaced intervals
- should generate
terrain that allows the exploration of hidden movement, line-of-sight, and
other important issues for small unit actions.
|
- should generate
terrain that is plausible
- should be capable
of generating different (random) terrain each time
- should be capable
of generating terrain of any arbitrary size
- should not employ
algorithms that are too computationally complex: i.e., there is no need to
model true geological forces
27.2 Basic Approach & Data Structure
• Basic Approach:
- employ a suite of
related functions which create and manipulate maps
- a function to
initiate the process with a random grid of heights
- functions to
“mimic” certain gross physical processes: weathering, river addition, meteor
impact, etc.
|
- each function is independent of the
others: the map data-type is simply passed to and from functions
• Data Structure:
- a 2D array
(matrix) matches the problem well
- element values for
the matrix represent the height at that point
- indices (row &
column) represent the evenly spaced horizontal grid atop which the heights
“sit”
Approach (Cont)
27.3 Map Creation – Algorithm
• Generate a map of
initial, random heights
• Notes:
- Matlab has
in-built uniform and normally distributed random number generators
Top-Level Algorithm
handle variable
arguments
if grid required
calculate meshgrid
generate a matrix
(map) of random values of the appropriate size
Handle Variable
Arguments
if no size specified
for the map then
set size to default (50x50)
else if only one
size specified
set 2nd size dimension to match the first
27.4 Map Creation – Example
original=mapGen(50,60);
surf(original);
shading interp;
colormap copper;
axis off;
<print>
contour(original);
colormap default;
axis off;
<print>
27.5 Created Map
27.6 Map Creation – Code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MAPGEN Generate a random map (grid of
% elevation
data)
% [X,Y,Z] = mapGen - Generate a 50x50 grid of
% elevation
data
% Z = mapGen - as above but without
the meshgrid
% (X
& Y)
%
% [X,Y,Z] = mapGen(N) - Generate an NxN grid
% of
elevation data
% Z = mapGen(N) - as above but
without the
% meshgrid
(X&Y)
%
% [X,Y,Z] = mapGen(N,M) - Generate an NxM
grid
% of elevation data
% Z = mapGen(N,M) - as above without
the
% meshgrid
(X & Y)
%
% Author: Spike
% Date: 11/10/98 (modified 1/4/1999)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [X, Y, Z] =
mapGen(xSize,ySize)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Provide a default
size if none given
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin==0
xSize=50;
ySize=50;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Else if a square
map then set both dimensions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif nargin==1
ySize=xSize;
end;
Map Creation Code
(Cont)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create x and y
arrays (vectors) ranging from 0
% to 1. These are
then used by meshgrid to
% generate the X
& Y matrices required by surf()
% and other 3D plot
functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargout==3
x=linspace(0,1,xSize);
y=linspace(0,1,ySize);
[X Y]=meshgrid(x,y);
% Make a grid of all x & y
combinations
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The
"real" work. Create a set of heights for
% the map as a
matrix of size xSize by ySize.
% Heights are
derived from a uniform
% distribution with
mean 0 and std. dev. of 1.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargout==3
Z=randn(xSize,ySize);
else
X=randn(xSize,ySize);
end;
27.7 Map Smoothing/Weathering – Algorithm
• Smooth/weather a
map an by averaging the height of a point with those about it
• Notes:
- the user may
specify how many times to apply the smoothing and what weighting to apply to
the old-point and those about it.
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program
matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER
ENGINEERING EXPERT (MEE) 0822 9988 2015.
Email: kursusmatlab@gmail.com
|
Top-Level Algorithm
handle variable
arguments
for the number of
smoothings requested
smooth the entire map
Smooth the Entire
Map
for each point on
the map’s surface
calculate the mean height of
the points
surrounding it
set new height as weighted sum
of old height
and mean height
of those surrounding
For each point on
the Map’s Surface
for every row in the
matrix
for every column (within the
row)
Note: Due to points
along edges of the map having less surrounding points, the four edges and the
four corner points are dealt with separately as special cases. Hence there
are actually 6 loops plus 4 special one-off cases: the double loop above for
the general cases (points not on an edge), one loop for each of the four
edges, and the four corners.
|
27.8 Map Smoothing – Example
after50=mapSmooth(original,50);
surf(after50);
shading interp;
colormap copper;
axis off
<print>
contour(after50);
axis off;
colormap default;
<print>
27.9 Smoothed Map
27.10 Map Smoothing – Code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MAPSMOOTH Smooth
an existing map (2D elevation data)
%
% map=mapSmooth(oMap) smooths an existing
map
% once with a weight
of 0.5 for surrounding
% points.
|
%
% map=mapSmooth(oMap,iterations)
repetitively
% smooths the map
`iteration' times.
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program
matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER
ENGINEERING EXPERT (MEE) 0822 9988 2015.
Email: kursusmatlab@gmail.com
|
%
%
map=mapSmooth(oMap,iterations,surroundWeight)
% repetively smooths
the map with the given
% weighting.
SurroundWeight should be within
% 0 to 1. 0 implies
no smoothing. 1 implies
% maximum smoothing.
|
%
% See Also mapGen, mapMeteor, mapPlateau,
% mapRiver, mapFloor
%
% Author: Spike
% Date: 11/10/98
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function smoothed =
mapSmooth(oMap,iterations,surroundWeight)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Default to only
one application of smoothing.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin==1
iterations=1;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% No weight
provided: defaults to 0.5 value.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin==1 |
nargin==2
surroundWeight=0.5;
end;
Map Smoothing Code
(Cont)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Determine the
edges of the map.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xUpper=size(oMap,1);
yUpper=size(oMap,2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main body of
program:
% for the number of
times smoothing must be applied
% for each row
% for each column on that row
% smooth the current point with those
% around it.
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya.
Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT
(MEE) 0822 9988 2015. Email:
kursusmatlab@gmail.com
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for
ntimes=1:iterations % For the
number of
% smoothings requested
for i=2:xUpper-1 %
For each row
% (besides
top& bottom)
for j=2:yUpper-1 %
For each column
% (besides left
and
% right most)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate smoothed
value at (i,j) as
% weighted sum of
old value and mean of
% those surrounding
it.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
surround=mean([oMap(i-1,j-1),oMap(i-1,j),
oMap(i-1,j+1),...
|
oMap(i,j-1),oMap(i,j+1),...
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program
matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER
ENGINEERING EXPERT (MEE) 0822 9988 2015.
Email: kursusmatlab@gmail.com
|
oMap(i+1,j-1), oMap(i+1,j),
oMap(i+1,j+1)]);
smoothed(i,j)=surroundWeight*surround + ...
|
(1.0-surroundWeight)*oMap(i,j);
end;
end;
Map Smoothing Code
(Cont)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The special cases
--> All along the edges.
% These don't have a
full 8 points surrounding
% them and hence the
smoothing is different
% Left-most and
right-most column
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:xUpper-1
smoothed(i,1)=(1.0-surroundWeight)*
oMap(i,1)+...
|
surroundWeight*mean([oMap(i-1,1),
oMap(i+1,1), oMap(i,2),...
|
oMap(i-1,2), oMap(i+1,2)]);
smoothed(i,yUpper)=(1.0-surroundWeight)* oMap(i,yUpper)+...
|
surroundWeight*mean([oMap(i-1,yUpper), oMap(i+1,yUpper),...
|
Kami ada di Jakarta
Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT
(MEE) 0822 9988 2015. Kami membuka
kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam
Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami
memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta
selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang kembali. Kami
juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan
dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822
9988 2015. Email:
kursusmatlab@gmail.com
|
oMap(i,yUpper-1),
oMap(i-1,yUpper-1), oMap(i+1,yUpper-1)]);
end;
%%%%%%%%%%%%%%%%%%%
% Top & bottom
row
%%%%%%%%%%%%%%%%%%%
for i=2:yUpper-1
smoothed(1,i)=(1.0-surroundWeight)*
oMap(1,i)+...
|
surroundWeight*mean([oMap(1,i-1),
oMap(1,i+1), oMap(2,i),...
|
oMap(2,i-1), oMap(2,i+1)]);
smoothed(xUpper,i)=(1.0-surroundWeight)*o Map(xUpper,i)+...
|
Kami ada di Jakarta
Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT
(MEE) 0822 9988 2015. Kami membuka
kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam
Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami
memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta
selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang kembali. Kami
juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan
dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822
9988 2015. Email:
kursusmatlab@gmail.com
|
surroundWeight*mean([oMap(xUpper,i-1), oMap(xUpper,i+1),...
|
oMap(xUpper-1,i),
oMap(xUpper-1,i-1), oMap(xUpper-1,i+1)]);
end;
Map Smoothing Code
(Cont)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The extra special
case of the four corners.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
smoothed(1,1)=(1.0-surroundWeight)*
oMap(1,1)+surroundWeight*mean([...
|
oMap(1,2), oMap(2,1), oMap(2,2)]);
smoothed(1,yUpper)=(1.0-surroundWeight)*
oMap(1,yUpper)+...
|
surroundWeight*mean([oMap(1,yUpper-1),
oMap(2,yUpper),...
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program
matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER
ENGINEERING EXPERT (MEE) 0822 9988 2015.
Email: kursusmatlab@gmail.com
|
oMap(2,yUpper-1)]);
smoothed(xUpper,1)=(1.0-surroundWeight)*
oMap(xUpper,1)+...
|
surroundWeight*mean([oMap(xUpper-1,1),
oMap(xUpper,2),...
|
oMap(xUpper-1,2)]);
smoothed(xUpper,yUpper)=(1.0-surroundWeight)*
oMap(xUpper,yUpper)+...
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program
matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER
ENGINEERING EXPERT (MEE) 0822 9988 2015.
Email: kursusmatlab@gmail.com
|
surroundWeight*mean([oMap(xUpper-1,yUpper), oMap(xUpper,yUpper-1),...
|
oMap(xUpper-1,yUpper-1)]);
oMap=smoothed;
end;
27.11 Crater Addition – Algorithm
• Add a meteor
impact crater to an existing map
• Note:
- user can specify
location, depth and radius for the impact
Top-Level Algorithm
handle variable arguments
for every point on
the map
if it lies within the crater then
set a new height of the crater depth
else if it lies on the crater’s rim
set a new crater rim height
else
leave the height unchanged
Handle variable
arguments
if no radius or
incorrectly specified radius
randomly determine one as
roughly 10% of the
smaller dimension
if no depth
specified then
randomly determine a depth as
roughly the lowest
point on the map
if no centre for
crater provided or out-of-bounds
randomly determine a centre
27.12 Crater Addition – Example
afterMeteor=mapMeteor(after50,10,min(min(after50)),30,30);
surf(afterMeteor);
axis off;
shading interp;
colormap copper;
<print>
contour(afterMeteor);
colormap default;
axis off;
<print>
27.13 Cratered Map
27.14 Crater Addition – Code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MAPMETEOR Add a meteor impact to an existing map.
|
%
% mapMeteor(oMap) - adds a single impact to
% the map such that
its depth is
% approximately that
of the lowest valley on
% oMap, and its
radius is approximately 10%
% of the smallest
dimension of the map.
|
% mapMeteor(oMap,radius) - adds a single
% meteor as above but
with radius of
% "radius"
units.
|
% mapMeteor(oMap,radius,depth) - as above
but
% uses the specified
depth.
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program
matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER
ENGINEERING EXPERT (MEE) 0822 9988 2015.
Email: kursusmatlab@gmail.com
|
%
mapMeteor(oMap,radius,depth,xCentre,yCentre) –
% as above but rather
than randomly located
% it is centred at
xCentre, yCentre.
|
%
% Author: Spike
% Date: 1/2/99
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function newMap =
mapMeteor(oMap,radius,depth,xCentre,yCentre)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Build the map to
hold the new depths
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
newMap=zeros(size(oMap,1),size(oMap,2));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We don't have an
acceptable radius. Make one
% as approximately
10% of the length of the
% shortest side of
the map.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (nargin==1 |
radius>min(size(oMap,1),size(oMap,2)));
radius=min(size(oMap,1),size(oMap,2))* …
(10.0+randn)/100.0;
end;
Crater Addition Code
(Cont)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We don't have a
supplied depth. Generate one
% that is roughly
the same as the current lowest
% valley.
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program
matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER
ENGINEERING EXPERT (MEE) 0822 9988 2015.
Email: kursusmatlab@gmail.com
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (nargin<3)
depth=min(min(oMap));
depth=depth*(100.0+randn)/100.0;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Find the
difference between the highest peak
% and lowest valley. This will be used
% subsequently to
try and place an appropriately
% sized rim around
the edge of the impact
% crater.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
difference=max(max(oMap))-depth;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% No centres
provided, or not valid centre.
% Generate a random
centre for the impact.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (nargin<5 |
xCentre<1 | xCentre>size(oMap,2) | yCentre<1 | yCentre>size(oMap,1))
xCentre=round(rand*size(oMap,2));
yCentre=round(rand*size(oMap,1));
end;
Crater Addition Code
(Cont)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For each point on
the surface determine
% whether it is now
part of the impact or not.
% If it is then set
its depth to be depth. If it
% isn't then
preserve the old height.
|
% NOTE: There should
be a "cleaner" way of doing
% this without loops
(such as the find()
% function) but the
calculate of inside or
% outside the circle
[needs to be done for i & j
% values
simultaneously] seems to preclude such
% an approach.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for
iIndex=1:size(oMap,2)
for jIndex=1:size(oMap,1)
distFromCentre=(iIndex-xCentre)*(iIndex-xCentre)+...
|
Kami ada di
Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING
EXPERT (MEE) 0822 9988 2015. Kami
membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin
memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering,
rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan
biaya 4-6 juta selama 10 kali pertemuan. Dijamin Bisa, atau bisa mengulang
kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya.
Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT
(MEE) 0822 9988 2015. Email:
kursusmatlab@gmail.com
|
KURSUS MATLAB ONLINE Skripsi, Tesis, DISERTASI 081219449060
Selasa, 13 Januari 2015
2D graphics and D graphics in Matlab
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar