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

Posted on 2009-04-21
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
    LVL 18

    Expert Comment

    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

    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

    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


    Author Comment

    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

    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

    The cylinder intercept

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
    Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now