已知矩形的中心点坐标、长度和宽度,可以通过以下步骤计算矩形四个顶点的坐标:

  1. 计算半长和半宽:

    c++

    double halfLength = length / 2.0;

    double halfWidth = width / 2.0;

  2. 计算四个顶点坐标:

    ```c++

    // 假设中心点坐标为 (centerX, centerY)

    double topLeftX = centerX - halfWidth;

    double topLeftY = centerY + halfLength;

double topRightX = centerX + halfWidth;

double topRightY = centerY + halfLength;

double bottomLeftX = centerX - halfWidth;

double bottomLeftY = centerY - halfLength;

double bottomRightX = centerX + halfWidth;

double bottomRightY = centerY - halfLength;

```

通过以上步骤,即可得到矩形四个顶点的坐标,从而构建矩形框。