Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
3D model of banana

Subject: 3D model of banana

From: striker

Date: 25 Jan, 2010 17:53:05

Message: 1 of 13

I want to create a 3D model of banana in matlab.how is it possible.

Subject: 3D model of banana

From: Walter Roberson

Date: 25 Jan, 2010 19:50:49

Message: 2 of 13

striker wrote:
> I want to create a 3D model of banana in matlab.how is it possible.

Sorry, Matlab is equipped with built-in self-defences against modelling
fresh fruit.


http://en.wikipedia.org/wiki/Self_Defence_Against_Fresh_Fruit

Subject: 3D model of banana

From: striker

Date: 25 Jan, 2010 20:28:05

Message: 3 of 13

Walter Roberson <roberson@hushmail.com> wrote in message <hjksmp$lde$1@canopus.cc.umanitoba.ca>...
> striker wrote:
> > I want to create a 3D model of banana in matlab.how is it possible.
>
> Sorry, Matlab is equipped with built-in self-defences against modelling
> fresh fruit.
>
>
> http://en.wikipedia.org/wiki/Self_Defence_Against_Fresh_Fruit

sorry i couldnot get ur point

Subject: 3D model of banana

From: John D'Errico

Date: 25 Jan, 2010 20:57:04

Message: 4 of 13

Walter Roberson <roberson@hushmail.com> wrote in message <hjksmp$lde$1@canopus.cc.umanitoba.ca>...
> striker wrote:
> > I want to create a 3D model of banana in matlab.how is it possible.
>
> Sorry, Matlab is equipped with built-in self-defences against modelling
> fresh fruit.
>
>
> http://en.wikipedia.org/wiki/Self_Defence_Against_Fresh_Fruit

No. That is not true. Only if you have the 16 ton
weight toolbox is that true. And do you have any
idea what the cost of shipping is for the 16 ton
weight toolbox? UPS makes you unload it from
the truck yourself too.

John

Subject: 3D model of banana

From: ImageAnalyst

Date: 25 Jan, 2010 22:56:20

Message: 5 of 13

On Jan 25, 12:53 pm, "striker " <friend_...@hotmail.com> wrote:
> I want to create a 3D model of banana in matlab.how is it possible.

----------------------------------------------------------------------------------------
Do you already have a list of (x,y,z) coordinates and you just need to
visualize/plot it? Or do you also need to get the coordinates in the
first place?
Did you check out the 3D visualization section in the Help?

Subject: 3D model of banana

From: Walter Roberson

Date: 25 Jan, 2010 23:17:56

Message: 6 of 13

striker wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message
> <hjksmp$lde$1@canopus.cc.umanitoba.ca>...
>> striker wrote:
>> > I want to create a 3D model of banana in matlab.how is it possible.

>> Sorry, Matlab is equipped with built-in self-defences against
>> modelling fresh fruit.

> sorry i couldnot get ur point

*Sigh* Have you ever considered the possibility of telling us what you
are actually trying to accomplish??


Which varietal of the over 200 kinds of bananas are you trying to model?

How many sides does the banana have? (Note: I have one here at home that
has one more side than the answer you'll find searching Google, so
you'll need to cross-check with actual examples of the varietal.)

Are the sides flat? Are they equal area? What is the cross-sectional
curvature of each? How does that curvature change along the length?

Are you able to create an adequate approximation of the colours
(including the specular reflectivity) using RGB or HSV? For example, the
  image here shows a good range of colours, but it also indirectly
illustrates the point that common image formats are poor at capturing
the specular information -- a point that will be important if you are
trying to create realistic CGI models for use in (say) a movie.
http://upload.wikimedia.org/wikipedia/commons/a/a1/RedBananasMetepec.JPG

What is the internal structure of the banana? How ripe is the banana?
How does the internal structure change with the ripeness? How do the
tensile, compressive, and shear stresses vary with the ripeness? I
understand that in some of the varieties of bananas, the phloem bundles
can be quite strong under tensile stress. The length and arrangement of
the fibres will be important if your purpose is to do a finite element
mesh examination of deformation of bananas under stress.

What is the chemical composition of the banana? How does that chemistry
change with heat? Does the rate of heating matter for this purpose? It
makes a difference if your purpose is to model the internal change of
bananas as they are roasted, or as they are prepared in lye for fibre
extraction.

And, as John mentioned, you may need additional toolkits if your purpose
is to model the use of bananas as attack weapons.

Subject: 3D model of banana

From: striker

Date: 26 Jan, 2010 12:22:04

Message: 7 of 13

I just want to create a model which looks like a banana.so that i can rotate it along any axis and i can scale it in any direction.

Subject: 3D model of banana

From: ImageAnalyst

Date: 26 Jan, 2010 13:19:20

Message: 8 of 13

On Jan 26, 7:22 am, "striker " <friend_...@hotmail.com> wrote:
> I just want to create a model which looks like a banana.so that i can rotate it along any axis and i can scale it in any direction.

----------------------------------------------------------------------------------------------------------------------------
Is it so important that it be a banana, specifically? Why can't you
do your little practice with, say, a klein bottle, for which MATLAB
already has a demo (see help on the xpklein function)

Simply type "xpklein" in the command window, or run the source code
for it (from the Help documentation):

n = 12;
a = .2; % the diameter of the small tube
c = .6; % the diameter of the bulb
t1 = pi/4 : pi/n : 5*pi/4; % parameter along the tube
t2 = 5*pi/4 : pi/n : 9*pi/4; % angle around the tube
u = pi/2 : pi/n : 5*pi/2;
[X,Z1] = meshgrid(t1,u);
[Y,Z2] = meshgrid(t2,u);

% The handle
len = sqrt(sin(X).^2 + cos(2*X).^2);
x1 = c*ones(size(X)).*(cos(X).*sin(X) ...
    - 0.5*ones(size(X))+a*sin(Z1).*sin(X)./len);
y1 = a*c*cos(Z1).*ones(size(X));
z1 = ones(size(X)).*cos(X) + a*c*sin(Z1).*cos(2*X)./len;
handleHndl=surf(x1,y1,z1,X);
set(handleHndl,'EdgeColor',[.5 .5 .5]);
hold on;

% The bulb
r = sin(Y) .* cos(Y) - (a + 1/2) * ones(size(Y));
x2 = c * sin(Z2) .* r;
y2 = - c * cos(Z2) .* r;
z2 = ones(size(Y)) .* cos(Y);
bulbHndl=surf(x2,y2,z2,Y);
set(bulbHndl,'EdgeColor',[.5 .5 .5])

colormap(hsv);
axis vis3d
view(-37,30);
axis off
light('Position',[2 -4 5])
light
hold off

Subject: 3D model of banana

From: Per Sundqvist

Date: 26 Jan, 2010 13:35:20

Message: 9 of 13

"striker " <friend_019@hotmail.com> wrote in message <hjmmpb$6v4$1@fred.mathworks.com>...
> I just want to create a model which looks like a banana.so that i can rotate it along any axis and i can scale it in any direction.

look at:
http://www.mathworks.com/matlabcentral/fileexchange/5562-tubeplot

or mine:
http://www.mathworks.com/matlabcentral/fileexchange/5468-cylinder-between-2-points

Not sure you can alter the radii along the tube for the first function. Paerhaps its a start?

/Per

Subject: 3D model of banana

From: striker

Date: 26 Jan, 2010 13:36:04

Message: 10 of 13

Yes the banana shape is important

Subject: 3D model of banana

From: Per Sundqvist

Date: 26 Jan, 2010 14:05:20

Message: 11 of 13

"striker " <friend_019@hotmail.com> wrote in message <hjmr44$jhg$1@fred.mathworks.com>...
> Yes the banana shape is important

If you modify the PlotTube function a little (see below)
http://www.mathworks.com/matlabcentral/fileexchange/5562-tubeplot

I can get a pretty nice banana with the code (change 20 to 7 and see what happen):

t=linspace(0,pi,50);
tubeplot([cos(t);sin(t);0*t],0.1*t.*(pi-t),20);axis equal
shading interp;lighting phong;light;axis off

/Per

My slightly fix of the original code below. Hope he doesn't mind... Copy and save as tubeplot.m
-------------------------------------------------------

function [x,y,z]=tubeplot(curve,r,n,ct)
% Usage: [x,y,z]=tubeplot(curve,r,n,ct)
%
% Tubeplot constructs a tube, or warped cylinder, along
% any 3D curve, much like the build in cylinder function.
% If no output are requested, the tube is plotted.
% Otherwise, you can plot by using surf(x,y,z);
%
% Example of use:
% t=linspace(0,2*pi,50);
% tubeplot([cos(t);sin(t);0.2*(t-pi).^2],0.1);
% daspect([1,1,1]); camlight;
%
% Arguments:
% curve: [3,N] vector of curve data
% r the radius of the tube
% n number of points to use on circumference. Defaults to 8
% ct threshold for collapsing points. Defaults to r/2
%
% The algorithms fails if you have bends beyond 90 degrees.
% Janus H. Wesenberg, july 2004

  if nargin<3 || isempty(n), n=8;
     if nargin<2, error('Give at least curve and radius');
    end;
  end;
  if size(curve,1)~=3
    error('Malformed curve: should be [3,N]');
  end;
  if nargin<4 || isempty(ct)
    ct=-1+0*0.5*r;
  end

  
  %Collapse points within 0.5 r of each other
  npoints=1;
  for k=2:(size(curve,2)-1)
    if norm(curve(:,k)-curve(:,npoints))>ct;
      npoints=npoints+1;
      curve(:,npoints)=curve(:,k);
    end
  end
  %Always include endpoint
  if norm(curve(:,end)-curve(:,npoints))>0
    npoints=npoints+1;
    curve(:,npoints)=curve(:,end);
  end

  %deltavecs: average for internal points.
  % first strecth for endpoitns.
  dv=curve(:,[2:end,end])-curve(:,[1,1:end-1]);

  %make nvec not parallel to dv(:,1)
  nvec=zeros(3,1);
  [buf,idx]=min(abs(dv(:,1))); nvec(idx)=1;

  xyz=repmat([0],[3,n+1,npoints+2]);
  
  %precalculate cos and sing factors:
  cfact=repmat(cos(linspace(0,2*pi,n+1)),[3,1]);
  sfact=repmat(sin(linspace(0,2*pi,n+1)),[3,1]);
  
  %Main loop: propagate the normal (nvec) along the tube
  for k=1:npoints
    convec=cross(nvec,dv(:,k));
    convec=convec./norm(convec);
    nvec=cross(dv(:,k),convec);
    nvec=nvec./norm(nvec);
    %update xyz:
    xyz(:,:,k+1)=repmat(curve(:,k),[1,n+1])+...
        cfact.*repmat(r(k)*nvec,[1,n+1])...
        +sfact.*repmat(r(k)*convec,[1,n+1]);
  end;
  
  %finally, cap the ends:
  xyz(:,:,1)=repmat(curve(:,1),[1,n+1]);
  xyz(:,:,end)=repmat(curve(:,end),[1,n+1]);
  
  %,extract results:
  x=squeeze(xyz(1,:,:));
  y=squeeze(xyz(2,:,:));
  z=squeeze(xyz(3,:,:));
  
  %... and plot:
  if nargout<3, surf(x,y,z); end;

Subject: 3D model of banana

From: striker

Date: 26 Jan, 2010 14:40:20

Message: 12 of 13

@ Per Sundqvist

Thank you very much sir..

Subject: 3D model of banana

From: Walter Roberson

Date: 26 Jan, 2010 22:48:40

Message: 13 of 13

striker wrote:
> Yes the banana shape is important

If the banana shape is important, then you still need to be able to answer
questions about the number of sides, relative proportions of the sides,
curvature of each of the sides, how the curvature varies along the length.

If you don't know that information, then you will not be able to "create a
model that looks like a banana": at best, you will be able to create something
that is a rough approximation of the shape of a banana -- and if all you
create is a rough approximation, then the banana shape is NOT important to you.

Any model will be an approximation, of course, but you have to decide which
features of the original must be represented and to what precision.

Have you at least taken a real banana and done some measurements with a ruler
and a French Curve?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us