Documentation

# `Points2d`, `Points3d`

List of 2D points

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Value Summary

 `Points2d`, `Points3d` Mandatory List of 2D points

## Description

`Points2d` is the list of 2D points in objects of type `plot::PointList2d` and `plot::Polygon2d`, respectively.

`Points3d` is the list of 3D points in objects of type `plot::PointList3d` and `plot::Polygon3d`, respectively.

One usually defines such an object `p`, say, via

```p := plot::PointList2d([[x1, y1], [x2, y2], …])``` or

```p := plot::Polygon2d([[x1, y1], [x2, y2], …])```, respectively.

Internally, the points are stored as the attribute

```Points2d = [[x1, y1], [x2, y2], …]```

and can be accessed via the slot call `p::Points2d`. Assigning a new list to `p::Points2d` changes the object `p` accordingly.

The corresponding statements hold for 3D point lists and polygons.

The points in the list `Points2d` may consist of lists with 2 elements (the x and y coordinates) or of lists with 3 elements (the x and y coordinates and the RGB color of the point).

The points in the list `Points3d` may consist of lists with 3 elements (the x, y, and z coordinates) or of lists with 4 elements (the x, y, z coordinates and the RGB/RGBa color of the point).

If you specify the color of one point, you must specify the colors of all other points in the list. See Example 2.

The points in the lists `Points2d` and `Points3d` can be animated.

## Examples

### Example 1

We define a 2D polygon with 5 points:

```p := plot::Polygon2d([[0, 0], [1, 1], [1, 2], [2, 2], [2, 1]]): plot(p):```

The points in the polygon can be accessed as the `Points2d` attribute:

`pts := p::Points2d`

We change the polygon be assigning a new point list:

```p::Points2d := [pts[1], pts[5], pts[2], pts[4], pts[3]]: plot(p):```

`delete p, pts:`

### Example 2

`Points2d` and `Points3d` allow you to specify the colors of the points. For example, the following list contains two points. The `plot` function uses the default color for both points on the plot:

```Coords := [[3, 4], [5, 5]]; plotCoords := plot::PointList2d(Coords): plot(plotCoords, PointSize = 5)```

To access and modify the list of points, use `Points2d`. For example, include the color of each point in the list:

`plotCoords::Points2d := [[3, 4, RGB::Red], [5, 5, RGB::Green]]`

Now the first point appears in red, and the second point appears in green:

`plot(plotCoords, PointSize = 5)`

If you specify the color of one point, you must also specify the colors of all other points in the list:

`plotCoords::Points2d := [[3, 4, RGB::Red], [5, 5]]`
```Error: Attribute 'Points2d' in the 'PointList2d' object must be a list of lists of two expressions and an optional color value. [plot] ```

#### Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos