How to draw a circle along the PQ Axis (3D WPF) (Refer the attached image)

Posted on 2009-04-21
Medium Priority
Last Modified: 2015-01-05
Actually we need to draw a circle, centre as P1 and radius is 2 and it should be Perpendicular to the line P1P2.

In Order to achieve this we need to calculate the point P3 and make it rotate around the arbitrary axis.

The Given things are

Point P1(-3,5,5)

Point P2(1,1,1)

Length (radius of circle) is 2

Angle between P1P2 and P1P3
is 90 degrees

Calculate P3 ??

Question by:isawme2002
  • 3
  • 3
LVL 18

Expert Comment

by:Jose Parrot
ID: 24212008
First move the line P1P2 such that P1 coincides with the orign, say P1=(0,0,0).
Anotate the displacements dx, dy and dz.
Then rotate the line P1P2 around P1, such that P1P2 coincides with the Z axis. P2 will be P2=(0,0,L), being L=lenght of P1P2.
Anotate the angles ax, ay and az and the order of ratation (1st, 2nd, 3rd)
Construct your circle by using the circle equation y² = R² - x² , being R the Radius.
Rotate back the line (and the circle) by using the inverse ordem (3rd, 2nd, 1st)
Move back both, by using -dx, -dy, -dz .

Author Comment

ID: 24214261
If i move the line alone the Z axis then the circular points will be perpendicular to (0,0,L)

The circular points should be along the P1P2 axis and not Z Axis. I am new to 3D. Can you Please explain it with an short example
LVL 18

Expert Comment

by:Jose Parrot
ID: 24215970
You're right, the circle will be on a plan parallel to XY plan, perpendicular to Z axis.
What I suggest is to create such points on XY plan (a simple task, as in pseudocode CODE 1 below) then rotate and translate the points to be perpendicular to P1P2 line.
It is a complex task, requiring 3D rotation and translation. To explain in details these subjects we need a very long text and some drawings to better clarification. In my books it takes several pages and a number of drawings.
If you are using WFP, why not ask WFP 3D functions to do it for you?
Take a look at the Microsoft site for WPF, specially the 3D graphics sector, at
and, more specifically, the transformations tutorial at
You can practice with the samples provided there, as the MatrixTransform3D Viewer Sample, and learn how to use the SDK to execute what you are looking for. Despite your claimed 3D lack of experience, on perceive you have the 3D insights and perception required to walk around the 3D world.

for p=0 to 359
   x = R * cos(angle)   // R is the radius, equal 2 in your case
   y = R * sin(angle)
   Point[p] = (x,y,L)   // L is the lenght of the P1P2 line
   angle = angle + delta

Open in new window

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 24224832
Hi jose,

Thanks for the concept. My whole idea was to draw a hollow pipe which is ziz zag with a smooth finish

in order to draw this pipe i breaked into small cylinders which passes through some paths.

the the previous question was only to draw a base of the cylinder. with a radius 2.

Is there any other easy way to draw a cylinder and in merging the two cylinder with smooth finish

This link is not working

Thanks and regards
LVL 18

Accepted Solution

Jose Parrot earned 2000 total points
ID: 24227800
About the not working link, please change the extension to aspx. My mistake.
About your new question (it is a new one, different of simply calculate P3), the difficult to answer in single comments or simple codes, as are normal in ee, sincerely, I don't know how to explain adequately.
If you are looking for concordance of cylinders, you should define the type of concordance you want, as in the figure: (1) the cylinders have a point of contact or (2) not or (3) they intercept themselves. Case they are apart, must be determined the smallest distance between them, among other conditions. If they intercept themselves, then should be defined how much one penetrates the other. Also must be determined if the concordance should be made by circular, ellyptical or other curve. In the figure, the samples have circular concordance.
The samples consider both cylinders regular, with same radius and with their axis in the same plane. The concordance would be complicated if the cylinders have different radius. And much more complicate if of the cylinders axes non coplanar.
Finally, on need define the graphic output: is it a parallel perpective? Solid rendering? Hidden line removal? What is the purpose of such concordance (a CAD like drawing, a 3D model)? Case it is for a model, then the surfaces are better described by triangular meshes. And, in this case, OpenGL is the best SDK to work with.


Author Comment

ID: 24257454
The cylinder intercept

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question