Main Content

and

Perform Boolean intersection operation on two shapes

Description

and(shape1,shape2) plots a shape generated by intersecting theshape1 and shape2. Alternatively, you can also use the '&' operator to intersect the shapes (shape1 & shape2).

example

c = and(shape1,shape2) generates the shape obtained by intersecting shape1 and shape2 and returns a polygon object for resultant 2-D shape or a custom 3-D object for resultant 3-D shape. Alternatively, you can also use the '&' operator to intersect the shapes (c = shape1 & shape2).

example

Examples

collapse all

Create a rectangular and circular shape and intersect them.
r  = antenna.Rectangle;
c  = antenna.Circle; 
r&c;

Figure contains an axes object. The axes object with xlabel x (mm), ylabel y (mm) contains 2 objects of type patch. These objects represent PEC, mypolygon.

This example shows how to create a custom shape using a 3-D trapezoid and sphere.

Create and view a 3-D trapezoid.

a = shape.Custom3D(Color=[0.9290 0.6940 0.1250]);
show(a)

Figure contains an axes object. The axes object with xlabel x (m), ylabel y (m) contains 2 objects of type patch.

Create and view a sphere.

b = shape.Sphere(Color=[0.9290 0.6940 0.1250]);
show(b)

Figure contains an axes object. The axes object with xlabel x (m), ylabel y (m) contains 2 objects of type patch.

Create and view the shape formed by the intersection of these two shapes.

c = and(a,b);
show(c)

Figure contains an axes object. The axes object with xlabel x (m), ylabel y (m) contains 3 objects of type patch.

Input Arguments

collapse all

Shapes to intersect, specified as objects from the following list:

Example: and(antenna.Rectangle,antenna.Circle)

Example: and(shape.Box,shape.Sphere)

Output Arguments

collapse all

Resultant shape after the Boolean intersection operation on two 2-D or 3-D shapes, returned as one of the following shape objects:

Example: antenna.Polygon

Example: shape.Polygon

Example: shape.Custom3D

Version History

Introduced in R2017a