# Change attachment point and rotate a cone

**URL:** <https://community.cesium.com/t/change-attachment-point-and-rotate-a-cone/20112>\
**Category:** CesiumJS\
**Created:** [August 25, 2022, 9:43am UTC](https://community.cesium.com/t/change-attachment-point-and-rotate-a-cone/20112 "2022-08-25T09:43:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vrana](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrana/32/2228_2.png) [@vrana](https://community.cesium.com/u/vrana)\
**Post date:** [August 25, 2022, 9:43am UTC](https://community.cesium.com/t/change-attachment-point-and-rotate-a-cone/20112/1 "2022-08-25T09:43:58Z")

</div>

I am trying to display a cone in front of the pilot. I am using `CylinderGraphics` which works great but the cone is displayed around the pilot and oriented downwards. Is it possible to:

1. Change the attachment point of the cone so that the pilot is at its tip and not in the middle?
2. Rotate the cone 90 degrees? I’m using `VelocityOrientationProperty` for the orientation of the entity.

This is an example of how it currently looks at [XCvid](https://xcvid.com/3245960?cone=100,30#113):

 ![image](https://global.discourse-cdn.com/cesium/original/3X/3/1/3168fc7bd73a23fcb40fc7114d8fc97075647c98.jpeg)

---

<div class="post-metadata">

**Author:** ![Corys\_atTheBeach](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/corys_atthebeach/32/14000_2.png) [@Corys\_atTheBeach](https://community.cesium.com/u/Corys_atTheBeach)\
**Post date:** [May 20, 2024, 10:21pm UTC](https://community.cesium.com/t/change-attachment-point-and-rotate-a-cone/20112/2 "2024-05-20T22:21:35Z")

</div>

Anyone have a solution for this? I need to do something similar. Thanks for the question.

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [May 21, 2024, 2:53pm UTC](https://community.cesium.com/t/change-attachment-point-and-rotate-a-cone/20112/3 "2024-05-21T14:53:22Z")

</div>

By default, the center of a `CylinderGraphics` will be the origin. When you want to use the top of a cylinder (or the “tip” of a _cone_, in your example) as some sort of a “reference point”, then you have to take this into account when computing the rotation- and translation matrices.

Assuming that you have a `rotationMatrix` for the orientation and a `translationMatrix` for the desired position, you can compute

- a `toOriginMatrix` to move the center of the coordinate system to the top of the cylinder
- a `fromOriginMatrix` to move the center of the coordinate system back

The final `modelMatrix` for the cylinder can then be computed like this:

```auto
  const modelMatrix = Cesium.Matrix4.clone(Cesium.Matrix4.IDENTITY);
  Cesium.Matrix4.multiply(modelMatrix, translationMatrix, modelMatrix);
  Cesium.Matrix4.multiply(modelMatrix, toOriginMatrix, modelMatrix);
  Cesium.Matrix4.multiply(modelMatrix, rotationMatrix, modelMatrix);
  Cesium.Matrix4.multiply(modelMatrix, fromOriginMatrix, modelMatrix);

```

An example can be found in the sandcastle that I posted in [Create a cylinder at a coordinate and point at another coordinate - #2 by Marco13](https://community.cesium.com/t/create-a-cylinder-at-a-coordinate-and-point-at-another-coordinate/25285/2) . It offers a function that receives to points, and generates a cylinder _between_ these points. (Applying arbitrary rotations could be done similarly)
