Cat Geometry
This example shows how to create a geometry representing a cat's head by using the geometry creation and modification functions available in Partial Differential Equation™ Toolbox.
Start creating the geometry with a sphere representing the head.
cat = fegeometry(multisphere(4));
Plot the geometry.
pdegplot(cat)
Next, create a geometry representing an ear by cutting a one-eighth of a sphere and stretching it so that the resulting geometry resembles a cat's ear. To cut the required piece of the sphere, create the geometries of a unit sphere and a unit cube.
sphere = fegeometry(multisphere(1)); cube = fegeometry(multicuboid(1,1,1));
Move the cube so that one of its corners coincides with the center of the sphere.
cube = translate(cube,[0.5 0.5 0]);
Find the intersection of the geometries by using the Boolean intersection operation.
ear = intersect(sphere,cube);
Plot the resulting geometry.
figure pdegplot(ear)
Stretch the geometry along the x-axis and z-axis.
ear = scale(ear,[1.8 1 4]); figure pdegplot(ear)
Move the geometry along the x-axis and z-axis so that when you combine the ear geometry with the head, the ear fits on top of the head and slightly to the right.
ear = translate(ear,[1.5 0 2.5]);
Combine the geometries representing the head and the ear by using the Boolean union operation. Plot the result.
cat = union(cat,ear); figure pdegplot(cat)
Create the geometry representing the other ear by mirroring the original ear geometry.
ear = scale(ear,[-1 1 1]);
Combine the geometries to add the second ear. Plot the result.
cat = union(cat,ear); figure pdegplot(cat)
Create three long, narrow cylinders to represent whiskers. The multicylinder
function creates vertical cylinders with their axis of symmetry located along the z-axis. Rotate each cylinder around the y-axis to place the cylinder horizontally. This step uses the coordinate center as a reference point. Then, rotate the cylinder by a small angle around the y-axis again, but this time use the center of the cylinder as a reference point. Move each cylinder to a suitable point, so that when you combine the cylinders with the cat
geometry, they look like whiskers. Combine the geometries.
for i=1:3 whisker = multicylinder(0.1,12); whisker = rotate(whisker,90,[0 0 0],[0 1 0]); whisker = rotate(whisker,-20+10*i,[6 0 0],[6 1 0]); whisker = translate(whisker,[-6 -2.5 0]); cat = union(cat,whisker); end
Plot the geometry.
figure pdegplot(cat)
Add the first eye by creating a small sphere, moving it to a suitable position, and combining it with the cat
geometry.
eye = translate(multisphere(1),[-1.2 -3 1]); cat = union(cat,eye);
Create the geometry representing the second eye by mirroring the original eye geometry.
eye = scale(eye,[-1 1 1]);
Combine the eye geometry with the cat geometry, and plot the result.
cat = union(cat,eye); figure pdegplot(cat)
Add the geometry representing the nose by creating a small sphere, moving it to a suitable position, stretching the sphere along the x-axis, and combining the result with the cat
geometry.
nose = translate(multisphere(0.5),[0 -3.8 -0.5]); nose = scale(nose,[1.5 1 1]); cat = union(cat,nose);
Plot the result.
figure pdegplot(cat)