×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# A challenge for Mathcad Prime 5.0

## A challenge for Mathcad Prime 5.0

(OP)
I am still waiting for PTC to get their act together. I have 25 years of Mathcad files.

I stopped upgrading at Mathcad 13. I use the symbolic solver a lot and PTC ruined it when they made Mathcad 14. Now I use Mathematica that is expensive. I also use Python with sympy to do symbolic processing.
So here is the challenge. Given 3 points solve for the center of the circle and radius to the 3 points.

This problem is simple enough to be entered in a few minutes.

#### CODE

from sympy import symbols, init_printing, sqrt
from sympy.solvers import solve

""" find the center and radius of a circle defined by three points """
init_printing()                         # enable pretty printing.
x0, y0, x1, y1, x2, y2, xc, yc, r = symbols('x0, y0, x1, y1, x2, y2, xc, yc, r')
eq0 = (x0-xc)**2 + (y0-yc)**2 - r**2
eq1 = (x1-xc)**2 + (y1-yc)**2 - r**2
eq2 = (x2-xc)**2 + (y2-yc)**2 - r**2
s = solve([eq0, eq1, eq2], (xc, yc, r))
# there are two solutions, r > 0 and r < 0
xc0, yc0, r0 = s
print("\nxc0 =",xc0)
print("\nyc0 =",yc0)
print("\nr0  =",r0)
xc1, yc1, r1 = s
print("\nxc1 =",xc1)
print("\nyc1 =",yc1)
print("\nr1  =",r1) 

Here is the output. There are two solutions because r can be positive or negative and still be valid as far as the problem goes but only the positive solution works.

#### CODE

xc0 = (x0**2*y1 - x0**2*y2 - x1**2*y0 + x1**2*y2 + x2**2*y0 - x2**2*y1 + y0**2*y1 - y0**2*y2 - y0*y1**2 + y0*y2**2 + y1**2*y2 - y1*y2**2)/(2*(x0*y1 - x0*y2 - x1*y0 + x1*y2 + x2*y0 - x2*y1))

yc0 = (-x0**2*x1 + x0**2*x2 + x0*x1**2 - x0*x2**2 + x0*y1**2 - x0*y2**2 - x1**2*x2 + x1*x2**2 - x1*y0**2 + x1*y2**2 + x2*y0**2 - x2*y1**2)/(2*(x0*y1 - x0*y2 - x1*y0 + x1*y2 + x2*y0 - x2*y1))

r0  = sqrt((x0**2 - 2*x0*x1 + x1**2 + y0**2 - 2*y0*y1 + y1**2)*(x0**2 - 2*x0*x2 + x2**2 + y0**2 - 2*y0*y2 + y2**2)*(x1**2 - 2*x1*x2 + x2**2 + y1**2 - 2*y1*y2 + y2**2))/(2*(x0*y1 - x0*y2 - x1*y0 + x1*y2 + x2*y0 - x2*y1))

xc1 = (x0**2*y1 - x0**2*y2 - x1**2*y0 + x1**2*y2 + x2**2*y0 - x2**2*y1 + y0**2*y1 - y0**2*y2 - y0*y1**2 + y0*y2**2 + y1**2*y2 - y1*y2**2)/(2*(x0*y1 - x0*y2 - x1*y0 + x1*y2 + x2*y0 - x2*y1))

yc1 = (-x0**2*x1 + x0**2*x2 + x0*x1**2 - x0*x2**2 + x0*y1**2 - x0*y2**2 - x1**2*x2 + x1*x2**2 - x1*y0**2 + x1*y2**2 + x2*y0**2 - x2*y1**2)/(2*(x0*y1 - x0*y2 - x1*y0 + x1*y2 + x2*y0 - x2*y1))

r1  = -sqrt((x0**2 - 2*x0*x1 + x1**2 + y0**2 - 2*y0*y1 + y1**2)*(x0**2 - 2*x0*x2 + x2**2 + y0**2 - 2*y0*y2 + y2**2)*(x1**2 - 2*x1*x2 + x2**2 + y1**2 - 2*y1*y2 + y2**2))/(2*x0*y1 - 2*x0*y2 - 2*x1*y0 + 2*x1*y2 + 2*x2*y0 - 2*x2*y1) 
The generated code is much more efficient that Mathcad 13. Notice I can use text which is very convenient for educational purpose or solving math for a webpage with a java script interface. Python will also generate LaTex for pretty printing on web pages.

What can Mathcad Prime 5.0 do?

Peter Nachtwey
Delta Computer Systems
http://www.deltamotion.com
http://forum.deltamotion.com/

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

#### Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a partâ€™s function at the center of their design considerations. Download Now
Industry Perspective: Education and Metal 3D Printing
Metal 3D printing has rapidly emerged as a key technology in modern design and manufacturing, so itâ€™s critical educational institutions include it in their curricula to avoid leaving students at a disadvantage as they enter the workforce. Download Now

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!