# 3D Points on Surface of a Pipe (Disk)

## Main Question or Discussion Point

Hello to all...first post here!

I need to compute 3D (x,y,z) points around the surface of a pipe. By pipe I mean something like an underground pipeline. Let's say I'm given the bottom point of the pipe in x,y,z coordinates, the diameter of the pipe (say 12 feet), and the inclination or slope of the pipe, such as +10 degrees from horizontal, and that the centerline of the pipe is facing 50 degrees Northeast (direction).

What I want to do is compute points at that location around the surface of the pipe, every 20 degrees around the pipe. In other words, I'm looking for a slice, or disk (I'm using the idea of a 'CD' as a section of the pipe). I just want to be able to compute x,y,z points at given arc degrees around the disk, such as every 20 degrees. If the inclination is 90 degrees (horizontal), then the solution is very straightforward. I just create the radius point of the "disk", and then compute my x,y, and z values in a relatively easy manner.

However, if the pipeline is inclined, then the values seem to be much more difficult to compute. I thought of computing the values as if at 90 degrees inclination and then rotating about the z plane, but this method doesn't seem to work.

I am doing this in a computer program to generate polygons that are used by a 3D viewer, to represent pipelines. For instance, if I have two "disks" with computed points around each disk every 20 degrees, I can easily create polygons that connect the two disks, and therefore, I have my 3D representation of the pipeline.

For computing the disk at 90 degrees inclination (horizontal), I have the following code for the first quarter of the disk (in surveying, Northings (N or n) are y, Eastings (E or e) are x, so RPn means the radius point northing or y value, and BottomN means the given bottom point's northing or y value):
RPn = BottomN
RPe = BottomE

Total = 0
Erase DiskPoints

'Right side of disk, top half
For i = 0 To 90.0# Step ArcDeg
ReDim Preserve DiskPoints(Total)

DiskPoints(Total).Y = RPn + (Math.Cos(RAD(NewAz)) * Rh)
DiskPoints(Total).X = RPe + (Math.Sin(RAD(NewAz)) * Rh)

Total = Total + 1
Next

So, any suggestions on how to compute the x,y,z coordinates of points around a disk, if the pipe is inclined?

Thanks, in advance for any and all replies!

domls

why isn't rotating the cylinder working?

another solution would be to find 3 points on the cylinder then solving the general eqn of a cylinder for a,b,R : (x-az)^2 + (y-bz)^2 = R^2

I'm not sure about my formulas for the rotation. One web site had the rotation about the z axis as being x'=x cos q - y sin q, y'= x sin q + y cos q, and z'=z. But I question that z'=z. I also found a web solution that talks about the general case of rotation about an arbitrary axis, but that solution didn't seem to work, at least if I implemented it correctly.

What I could really use is a "real" example with numbers so I can check my computations, in other words, a "one disk" solution. It could be something fairly simple, such as a radius of 10, bottom coordinates of 0,0,0, inclination of 15 degrees, and desired arc angle of every 10 degrees.

domls

again why doesn't the general rotation work? it must be a mistake in your code because it is a well founded method of rotatiting points in 3space.

Yes, I agree. However the formula is the question. What formulas would you use to perform the rotation?

domls

do you know how to work with matrices?

http://mathworld.wolfram.com/RotationMatrix.html

matrices (4),(5), and (6) help you achieve any rotation you want by composing two. be careful the SO(3) group (the collection of all 3d rotation matrices) is not abelian meaning it matters in which order you compose those matrices but your spatial intuition should help you out.

if you don't know how to work with matrices say so and i'll take some time to write something up for you.

I do know how to work with matrices. Over the years, as a registered professional land surveyor and programmer since 1983, I have developed many subroutines that are used to multiply, add, subtract, transpose, etc, matrices. I have developed least squares subroutines such as best fit line and best fit curve. I have also developed subroutines for NAD27 and NAD83 coordinate projection solutions (lat/long to NAD27/83 and inverse routines). However, as a 20+year programmer, I wonder why others always rely on matrices to perform relatively simple calculations, such as a 3x3 rotation of x,y,z coordinates. Why not simply relate the answer as a formulae solution, as opposed to a matrix solution? Also, I wonder why answers found on the internet routinely use simple 0,1,0 coordinates & -1,0,-1 answers when a real-world example is always much easier to follow.

With this in mind, would it be possible to show a real-world example, starting with a bottom coordinate of 1000x,1000y,100z, a pipe diameter of 12', an inclination of +10 degrees, an Azimuth of 52 degrees, and the need to compute every 10 degrees radially around the disk, and actually show the x,y,z of each computed point?

Thanks!

domls

is (1000,1000,100) the coordinate of the center of the pipe?

No, that is the bottom coordinate of the pipe. I can easily compute the RP (radius point) or center of the pipe given the inclination and azimuth.

Thanks.

please do because for me the problem is ill defined

Here is a picture tutorial:
http://img138.imageshack.us/img138/226/circlesvectoron8.png [Broken]

It will help a lot if you are comfortable with vectors.

Last edited by a moderator:
I would like to attempt an answer to your question concerning the (1000, 1000, 100) coordinates. Perhaps this will also shed some light on why you do not get the answers you were expecting.

First of all, in your first post you inferred that you were using an East(X), North (Y), Up (Z) coordinate system. So I’d like to change the coordinates to (1000, 1000, -100) which puts the pipe underground.

Next, per ice109’s recommendation, use the center of the pipe instead of the bottom to indicate the location of the pipe center, and assume that (1000, 1000, -100) are the coordinates of the center. In fact, since we are dealing in this example with only a cross section, let’s talk about a circle and rephrase the problem as:

Suppose we have a 12 unit diameter circle centered in the XZ plane, and suppose that there are points on that circle every 10 degrees measured from the X axis positive towards the Z axis. What will be the coordinates of the points if the they are rotated about the Z axis to an azimuth of 52 degrees , then rotated about the new E axis to an inclination of 10 degrees, then translated to the coordinates (1000, 1000, -100).
A solution to this example is:

1. Use a polar to Cartesian conversion procedure to compose a list of points in the XZ plane every 10 degrees, starting at X axis and moving along the perimeter towards the Z axis.

2. Rotate these points to an azimuth of 52 degrees (a rotation of -52 degrees about the Z axis

3. Rotate these points to an inclination of +10 degrees ( a rotation of +10 degrees about the new E axis).

4. Translate these points 1000 units in the East direction, 1000 units in the North direction, then -100 units in the Z direction.

5. Once everything checks out you can verify that the rotation matrices may be concatenated so that only one is required for the rotations in azimuth and inclination.
The matrices from the Mathematica web site are called alias transformations, meaning that when they multiply vectors, the vectors are represented in a rotated coordinate system. This is standard. Since you will be rotating vectors, use their transposes.

My summary of this exposition is that there are 1001 ways to get a sign, an axis, or a matrix wrong here, and I have probably made a mistake myself, since I did not check this whole thing out. However the matrix approach is the only way to go, and it provides you with real power when you model surfaces and use homogeneous coordinates.

PS I've been trying to format this thing using the tab but its not working too well.