# How to find where a cylinder's ends and middle are?

I might be totally off the base here, so let me explain the problem I'm solving - perhaps there's some very elegant solution I'm totally missing.

The following is pseudo-code. If that's not enough I can post the real one.

So I have a randomly placed (setLocalRotation(RandomAxle,RandomAngle), setLocalTranslation(RandomX,RandomY,RandomY) cylinder. Then cylinder randomly increases height and radius. At some point in the application, I want to add another cylinder in such a way so the "beginning" of the second cylinder is connected to the first cylinder in some way (assume it start at the radius-delta) at the "end" of the first cylinder. I have no problem "memorizing" the settings I used to create the first cylinder.

I can not figure out how to calculate LocalTranslation for the second cylinder. Also, I'd like second cylinder to have certain randomness in its direction, too. Obviously, its axis needs to intersect the axis of the first cylinder, but the angle can be pretty much random.

Any help will be very much appreciated.

I just need to know how to find the coords of cylinder's ends having a reference to Cylinder object. How hard can that be?!

Should be pretty simple…  take a vector3f(0,0,0.5f * cylinder's height)  - or negative halfHeight for the other end.

call cylinder.localToWorld and pass in your vector.

take a vector3f(0,0,0.5f * cylinder's height)  - or negative halfHeight

I was missing the understanding of what local coordinates actually are. I didn't realize it stays with the instance over all its rotations and scaling. Thanks a lot!