Is it possible to enter a function / equation to define a line / edge?
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by kasperwuyts. Go to Solution.
Solved by JDMather. Go to Solution.
Can I enter an equation like y = 2x^3 + 3x +15, with a restricted domain to define a line, so that I can then rotate it on an axis to create a solid?
@SRB_Math wrote:
Can I enter an equation like y = 2x^3 + 3x +15, with a restricted domain to define a line, so that I can then rotate it on an axis to create a solid?
I still have no idea what you mean by "with a restricted domain". But you can perform calculations using the QUICKCALC command which should help you.
Don Ireland
Engineering Design Technician
@SRB_Math wrote:
Can I enter an equation like y = 2x^3 + 3x +15, with a restricted domain to define a line, so that I can then rotate it on an axis to create a solid?
As far as I know, the answer is no, but one could pretty easily convert a function like that into an AutoLISP expression in a routine that would ask for the domain [minimum and maximum values for X] and a precision [how closely spaced in the X direction you want points calculated], calculate the Y values for each X position, and draw for example a Spline or Polyline along the calculated route; the Polyline version could then be smoothed with PEDIT's Fit or Spline option if desired. Does that sound like it would work for you?
[By the way, an equation like that certainly wouldn't define a "Line" in AutoCAD's use of the word, but I think I know what you mean.]
For instance [minimally tested, and taking the default end tangent directions, without the usual controls, etc.]:
(defun C:EQUATION3 (/ mult3 mult2 mult1 const minX maxX inc n)
(setq
mult3 (getreal "\nMultiplier on X^3: ")
mult2 (getreal "\nMultiplier on X^2: ")
mult1 (getreal "\nMultiplier on X: ")
const (getreal "\nConstant: ")
minX (getreal "\nMinimum X value: ")
maxX (getreal "\nMaximum X value: ")
inc (getreal "\nPrecision [increment between X values]: ")
n -1
); setq
(command "_.spline")
(repeat (1+ (fix (/ (- maxX minX) inc)))
(command ; feed out to Spline command
(list
(setq x (+ minX (* inc (setq n (1+ n)))))
(+
(* mult3 (expt x 3))
(* mult2 (expt x 2))
(* mult1 x)
const
); +
); list
); command
); repeat
(command "" "" "")
); defun
In your example case, answer 0 for the multiplier on X^2. All supplied answers can be positive or negative, whole or decimal numbers, etc.
@SRB_Math wrote:
Can I enter an equation like y = 2x^3 + 3x +15, with a restricted domain to define a line, so that I can then rotate it on an axis to create a solid?
You can do this in Autodesk Inventor with Equation Curves.
Here is an example (but not with your equation).
http://help.autodesk.com/view/INVNTOR/2015/ENU/?guid=GUID-8BF2EEB8-3A64-43F1-BA75-5ECBE357F08C
Students can download Inventor from http://www.autodesk.com/edcommunity
@Kent1Cooper wrote:
.... All supplied answers can be positive or negative, whole or decimal numbers, etc.
...except that, of course I should have said, 'inc' can't be zero or negative -- it would be better done this way:
....
inc (getdist "\nPrecision [increment between X values]: ")
....
@kasperwuyts wrote:
How Autodesk would recommend doing it: ....
Wow -- that's pretty cumbersome, especially considering that you'd need to go through that entire rigmarole, including making a complete and distinct set of Excel and Word and .scr files separately for every such equation with different multipliers and constant and bounds that you want to draw. If a Polyline such as that would make will do for you instead of a Spline, just take mine and remove the s from "_.spline" and the last two "" Enters from the (command) function that has three of them.
@SRB_Math wrote:
Is it possible to enter a function / equation to define a line / edge?
I came up with a more sophisticated routine for AutoCAD, PolynomialFunction.lsp with its PF command, to draw a Polynomial Function in the form Y = a series of descending powers of X with coefficient multipliers, and a constant.
It gives you the following choices:
A. whether to draw a Spline or a Polyline;
B. the X-Y axis intersection origin point to build it around [it puts a Point entity there for reference];
C. the degree [highest exponent on X -- I tried it even up to X^17];
D. the coefficient applied to each power of X [positive, negative or 0];
E. the constant number [positive, negative or 0];
F. the bounds [either as numbers relative to the origin or by picking points from which it will take their X coordinates];
G. the precision [increment in X direction between calculated values of Y].
And it remembers all your choices, and offers them as defaults on subsequent use. See a few additional things to know, in the comments at the top of the file.