News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Trivial BasicCAD problem. Help!

Started by j-wetzel, August 26, 2014, 01:52:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

j-wetzel

Fifteen or so years ago I used BasicCAD to plot graphs for several articles.  Now (at age 82) I need to do so again, and I simply cannot get the darn thing to work.  I can't get the {, [, }, ] thingys in the right places.  The program is short and transparent.  HELP, somebody, please:

  INPUT "Enter the coordinates of P:  ",  a, b
     s = SQRT(3)
     f(x) = x/s + sqrt((x - a)^2 + (x/s - b)^2)
  INPUT "Enter the step size d:  ",  d
     t = 0
     z = 0
   >CURVE
   {
     DO While t <= 10
     x = t
     y = f(t)
   >pointxyz [x,y,z]
     t = t + d
   Loop
   }
   >END

Now! the program is as I wrote it; and it still doesn't work.
--Jack

prl

Jack,

what are the values for a and b?

prl

Quote from: j-wetzel on August 26, 2014, 01:52:09 PM
sqr(x/s - b)^2

Jack, also what you are trying to get in the above expression, it reads ((x/s-b)^2)^2, is that what you mean?

j-wetzel

Sorry!  I was rushed entering the idiotic program, and messed up.  It's right now, i.e., it's as I wrote it, expecting it to work.  But it doesn't.  What have I screwed up?
--Jack

prl

Jack,

See if this is what you intended.


INPUT "Enter the coordinates of P (a,b):  ",  a, b
s = SQRT(3)
INPUT "Enter the step size d:  ",  d
t = 0
z = 0
>CURVE
  {
   DO While t <= 10
   x = t
   y = x/s + sqrt((x - a)^2 + (x/s - b)^2)
   <pointxyz [x,y,z]
   t = t + d
  Loop
  }
END

j-wetzel

Enormous thanks, PRL.  As a many-years-retired mathematician, I think in terms of functions, so defining the function that gives the ordinate seemed entirely natural to me.  But moving the definition down to where it was needed worked; and I would never have thought to try that.  <sigh>

Thanks again.
--Jack

samdavo

#6
J-wetzel
Looks a bit like a J curve.
There's something about J curves that gives one hope yes?
Is that where you get your nicname ? :)

PS Here's a run with a,b = 4,6,  and step = 1.
I assume that 'a' has to be less than 10?  (otherwise there is no minimum yes?)

Also several graphs superimposed.
a,b = 2,6 >red
a,b = 4,6 >green
a,b = 6,6 >cyan
a,b = 8,6 >magenta  (2 cents).

One comment:-  I'm thinking it might be more useful (in general) if those curves were parabolic (about vertical axis)?

samdavo

#7
Herewith a modified macro that gives parabolas with either a maximum or minimum (depending on the choice of yo, and a,b.)
If 'yo' is less than b, you get a maximum,
if greater than b, you get a minimum (2 cents) 
Again a should be less than 10.

Quote
'graph2.d3m draws a parabolic curve in the range x=0 to x=10
'starting at (0,yo)
'with a maximum or minimum at P, (a,b)
'with points plotted at step size d  eg 1
INPUT "Enter the coordinates of start point y coord on Y axis :  ",  yo
INPUT "Enter the coordinates of P (a,b), with 'a' less than 10:  ",  a, b
INPUT "Enter the step size d:  ",  d
t = 0
z = 0
c = (yo - b) / a^2
>CURVE
  {
   DO While t <= 10
   x = t
   y = c * (x - a)^2 + b
   <pointxyz [x,y,z]
   t = t + d
  Loop
  }
END

j-wetzel

   Thanks for all your interest!  Functions of the form

                          mx + ny + sqrt((ax + by + c)^2 + (px + qy + r)^2) = 0

(where m, n, a, b, c, p, q, and r are fixed (real) numbers) always have graphs that are (pieces of) conics or degenerate conics and have been well understood since the days of Euclid and Apollonius, even before the invention of algebra.  Transposing the linear x and y terms on the left to the other side, squaring, and collecting terms gives an equation of the form

                          Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0,

which every analytic geometry students knows how to analyze.
   In the case of my post, the graph is necessarily the upper branch of a hyperbola, so its general shape is known in advance.  The equation arises from a geometric problem far removed from this specific situation.
--Jack

samdavo

Thanks Jack,

I believe what you have started here is worth pursuing.
For instance, whenever we drive around our respective towns, we see countless catenary curves (assuming you have overhead power cables).
I might start a new thread on just that topic :)
cheers
sam