Download Software Transtool Versi 10.0
Mathematical Functions in AutoCAD Example: The catenary function by Héctor Monroy, BSCE, MSCE, MSEC CAD Manager. CSA group, Inc. |
||
Sometimes
engineers lose one of their most powerful tools when they
use one of their most powerful tools -- the mathematical
tool that's right inside the software.
AutoCAD
is very good drafting software for making arcs and lines, but sometimes
this simple view of things is not sufficient to represent typical engineering
graphics. For example: if we have a cable supported by two towers, we
need to define catenary curve to represent the cable, yet AutoCAD doesn't
have a "catenary" command. Also, if you need to analyze a
beam deflection there isn't an easy way to do it.
The
real CAD tool power is the possibility of using CAD with a geometric
calculator, not only for measuring areas and distances, but to graph
complex functions. This article brings you a small AutoLISP routine
to demonstrate how to graph mathematical functions and parametric equations.
If
you know AutoLISP, skip the next two paragraphs. If you don't know AutoLISP,
you'll need to understand how to write mathematical expressions in AutoLISP.
First
rule: All AutoLISP expressions are written between parentheses.
Second rule: all mathematical expressions are written in prefix notation. Third rule: mathematic operations between real numbers produce real numbers, between integers produce integers and between integers, and real produce real.
Examples:
1 +
3 is (+ 1 3) in AutoLISP
1 + 2 / 4 is (+ 1 (/ 2 4)) in AutoLISP
(+
1 3) = 4
(+ 1.0 3) = 4.0 (/ 5 3) = 1 (/ 5.0 3) =1.66667 To understand in depth, see your AutoLISP manual. EVALUATING FUNCTIONS IN THE XY PLANE
Typically,
AutoCAD users work in the XY plane, X values increasing left to right
and Y values increasing bottom to top. In the graphfx.lsp
file, the GraphFx AutoLISP function evaluates a mathematical expression
in the form Y=F(X) and returns a sorting list with the evaluated points.
The
AutoLISP function has four arguments: the mathematical function Y=F(X)
in AutoLISP terms, the first X value, the last X value and the increasing
value to X.
The
AutoLISP function Printpntlst graphs a 3DPOLYLINE using a list with
sorted points.
For
example to generate a list with evaluated points using the trigonometric
function sin(x) between 0 and 10 increasing x in 0.1, you need to write
the following expression in the AutoCAD command line:
(graphFx '(sin x) 0 10 0.1)
To
print the points, write
(Printpntlst (graphFx '(sin x) 0 10 0.1)) sin(x) graphic
Also,
you can generate more complex and practical graphs. For example, the
following equation defines the deflection curve for a propped cantilever
beam with a uniform load (q):
to
express the last equation in AutoLISP you need to write the following
line:
(* (/ (* q x x) (* 48 E I)) (+ (* 3 L L) (* -5 L x) (* 2 x x)))
If
the length (L) of the beam is 10m and simplifying and scaling the expression
only for demonstration we have:
(printpntlst (graphFx '(* x x -0.0005 (+ 300 (* -50 x) (* 2 x x))) 0 10 0.1)) Deflection curve for a propped cantilever beam EVALUATING PARAMETRIC FUNCIONS IN THE XYZ SPACE
If
we have a graph described by three functions, one for X coordinate,
one for Y coordinate, one for Z coordinate and a common parameter we
can use the GraphPar AutoLISP function (graphfx.lsp).
This
AutoLISP function has six arguments: three mathematical functions X=F(q),
Y=F(q) and Z=F(q) in AutoLISP terms, the first q parameter value, the
last q parameter value and the increasing value of q.
For
example, we can describe such parabolic motion with parametric equations
in the XY plane using a time parameter q measured in time units from
the initial projection point:
Expressing the last equations in AutoLISP we have:
(+
X0 (* Vx0 q))
(+ Y0 (* Vy0 q) (* 0.5 g q q)) 0
If
q start in 0 and end in 200, X0=0, Y0=0 and simplifying and scaling
the parametric function we have:
(printpntlst (graphpar '(* 100 q) '(- (* 100 q) (* q q)) '0 0 200 1)) Parabolic motion
THE
CABLE PROBLEM
One
of the most typical problems in engineering is to fix a cable between
two points. The function to describe the shape is a catenary. The mathematical
expression is:
Where w is the weight per unit length of the cable, t is the tension developed in the cable, and y0 is the minimum height of the cable.
AutoLISP
don't have the hyperbolic cosine, but that is not a problem since we
can define it with the following function
(defun
cosh(angles / angles)
(/ (/ (+ (exp angles)(exp (* angles -1))) 2)) )
In
the catenary.lsp file
we have a routine to print a cable between two points defined the points
in AutoCAD, the weight per unit length of the cable and the tension.
The file has three additional functions: hyperbolic cosine (cosh), hyperbolic
sine (sinh), and arc hyperbolic sine (arcsinh)
Below
we can see the graphFx AutoLISP use in the c:catenary function:
(printpntlst
(graphFx '(+ (* global_c (- (cosh (/ (- x global_xv) global_c)) 1))
global_yv) x1 x2 1.0))
Cable between two points CONCLUSION
With
the GraphFx and GraphPar AutoLISP routines we can graphic mathematical
functions, also we can include the routines inside others routines within
we like to have only the kernel of a specific problem (i.e. The cable
problem).
[an error occurred while processing this directive]
|