Main Content

intersect

Generate and plot intersection of two shapes

Description

intersect(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 = intersect(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 default rectangle.

r = antenna.Rectangle;

Create a default circle.

c = antenna.Circle;

Use intersect to combine the shared surfaces of the rectangle and the circle.

rc = intersect(r,c)
rc = 
  Polygon with properties:

        Name: 'mypolygon'
    Vertices: [12×3 double]

show(rc)
axis equal

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.

Intersect the 3-D trapezoid with the sphere and view the resultant shape.

intersect(a,b);

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: intersect(antenna.Rectangle,antenna.Circle)

Example: intersect(shape.Custom3D,shape.Sphere)

Output Arguments

collapse all

Resultant shape after the 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