# How to get from 2 endpoints of a line to xyz location and xyz rotation?

**URL:** <https://forums.unrealengine.com/t/how-to-get-from-2-endpoints-of-a-line-to-xyz-location-and-xyz-rotation/438724>\
**Category:** Community & Industry Discussion\
**Tags:** math, rotation, conversion, line, unreal-engine, question\
**Created:** [December 2, 2018, 9:25pm UTC](https://forums.unrealengine.com/t/how-to-get-from-2-endpoints-of-a-line-to-xyz-location-and-xyz-rotation/438724 "2018-12-02T21:25:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_33991355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33991355](https://forums.unrealengine.com/u/anonymous_user_33991355)\
**Post date:** [December 2, 2018, 9:25pm UTC](https://forums.unrealengine.com/t/how-to-get-from-2-endpoints-of-a-line-to-xyz-location-and-xyz-rotation/438724/1 "2018-12-02T21:25:42Z")

</div>

I have the end points of a line (x1;y1;z1) and (x2;y2;z2). How do I calculate the x-y-z-rotation (of thin cylinders) so Unreal gives me this line, starting at one point and pointing in the right direction (and ending in the second point)? The x-y-z-location for the cylinder is “easy”, (x2-x1;y2-y1;z2-z1).

I have tried this: [Spherical coordinate system - Wikipedia](https://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates), putting inclination in y, azimuth in x, and z=0, gave not the result I wanted.

I’m trying to recreate something like this:

![261131-square.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/0/c202871fa0983f1df611d59d8181ce7cc05e7ef6.jpeg)

It consists of all straight lines, still gives the impression of a curved surface.  
I have tried positioning the cylinders manually, didn’t succeed as rotation is done around the center, not the endpoint of an actor.  
In total I have 19 lines, for which I have the endpoints calculated.

![261134-element.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/d/62d42ce2f53ec5a9cb5e427f87eaeced7d633fcf.jpeg)
