genspheres
Description
Examples
Generate Collision Spheres Inside Collision Capsule
Create a collision capsule with a radius of 2
and length of 10
. Visualize the capsule.
cCapsule = collisionCapsule(2,10); [~,p] = show(cCapsule);
Generate spheres at ratios 0.0
, 0.5
, and 1.0
of the capsule length.
spheres = genspheres(cCapsule,linspace(0,1,3));
Display the positions of the spheres.
for i = 1:length(spheres) disp(tform2trvec(spheres{i}.Pose)) end
0 0 -5 0 0 0 0 0 5
Set the face and edge alphas of the capsule to low values. This ensures that both the spheres are visible when you add them to the figure.
p.FaceAlpha = 0.4;
p.EdgeAlpha = 0.01;
hold on
Display the generated spheres on the capsule.
cellfun(@show,spheres);
Input Arguments
capsule
— Collision capsule
collisionCapsule
object
Collision capsule, specified as a collisionCapsule
object.
Example: collisionCapsule(3,5)
ratio
— Normalized positions along central line segment of collision capsule
N-element row vector of values in range [0, 1]
Normalized positions along the central line segment of the collision capsule, specified as an N-element row vector of values in the range [0, 1]. N is the number of collision spheres to generate. Each element specifies the position of a sphere as a percentage of the central segment length.
Example: For collision capsule with a central line segment length of 4 meters, a
ratio position vector [0.25 0.5 0.75]
generates collision spheres at
1, 2, and 3 meters along the central line segment of the collision
capsule.
Output Arguments
spheres
— Collision spheres
N-element cell array
Collision spheres, returned as an N-element cell array of collisionSphere
objects, where N is the number of
generated collision spheres.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
The ratio
input argument must be specified as a compile-time
constant during code generation.
Version History
Introduced in R2022b
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)