discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Is it possible to assign a global variable at run time?

RW
Ray West
Mon, May 10, 2021 9:33 PM

    A= 30;
                b= 25;
                c=  40;
                a =sqrt(b^2 + c^2 - 2 * b * c * cos(A));
                echo ("line 56 ",A,B,C,a,b,c);

works, I guess a given value is wrong.

On 10/05/2021 22:20, lar3ry wrote:

Thanks! Got another problem with a formula. Here's a snippet

        if (formula==43) {
                A=given[0]; // 30
                b=given[4]; // 25
                c=given[5]; // 40
                a =sqr(b^2 + c^2 - 2 * b * c * cos(A));
                echo ("line 56 ",A,B,C,a,b,c);

and the result of the echo is:
ECHO: "line 56 ", 30, 0, 0, 242999, 25, 40

The answer should be 22.20 according to the http://cossincalc.com
http://cossincalc.com site.

    nophead wrote
    If you mean sin to the -1 it means arcsine, which is asin() in
openscad.
    I.e. the inverse of sin.

    > What the heck does the '-1' in that formula mean?

Sent from the OpenSCAD mailing list archive
http://forum.openscad.org/ at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

    A= 30;                 b= 25;                 c=  40;                 a =sqrt(b^2 + c^2 - 2 * b * c * cos(A));                 echo ("line 56 ",A,B,C,a,b,c); works, I guess a given value is wrong. On 10/05/2021 22:20, lar3ry wrote: > Thanks! Got another problem with a formula. Here's a snippet > >         if (formula==43) { >                 A=given[0]; // 30 >                 b=given[4]; // 25 >                 c=given[5]; // 40 >                 a =sqr(b^2 + c^2 - 2 * b * c * cos(A)); >                 echo ("line 56 ",A,B,C,a,b,c); > > and the result of the echo is: > ECHO: "line 56 ", 30, 0, 0, 242999, 25, 40 > > The answer should be 22.20 according to the http://cossincalc.com > <http://cossincalc.com> site. > >     nophead wrote >     If you mean sin to the -1 it means arcsine, which is asin() in > openscad. >     I.e. the inverse of sin. > >     > What the heck does the '-1' in that formula mean? > ------------------------------------------------------------------------ > Sent from the OpenSCAD mailing list archive > <http://forum.openscad.org/> at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
L
LenStruttmann
Mon, May 10, 2021 9:41 PM

The square root function is sqrt().  You've got sqr().

--
Sent from: http://forum.openscad.org/

The square root function is sqrt(). You've got sqr(). -- Sent from: http://forum.openscad.org/
L
lar3ry
Mon, May 10, 2021 9:48 PM

Hmm...
A= 30;
b= 25;
c=  40; a =sqr(b^2 + c^2 - 2 * b * c * cos(A));
echo ("line 56 ",A,B,C,a,b,c);

ECHO: "line 56 ", 30, 0, 0, 242999, 25, 40

This is with OpenSCAD version 2021.04.21.ai7788 (git d9d4a9757)

Exactly the same result with OpenSCAD version 2019.05
A= 30;
b= 25;
c= 40;
a =sqr((bb) + (cc) - 2 * b * c * cos(A));
echo ("line 56 ",A,B,C,a,b,c);

ECHO: "line 56 ", 30, 0, 0, 242999, 25, 40

I am unable to test with 2021.01 because on the OpenSCAD download page,
sudo apt-get install openscad
gives me 2019.05

mondo wrote

    A= 30;
                b= 25;
                c=  40;
                a =sqrt(b^2 + c^2 - 2 * b * c * cos(A));
                echo ("line 56 ",A,B,C,a,b,c);

works, I guess a given value is wrong.

On 10/05/2021 22:20, lar3ry wrote:

Thanks! Got another problem with a formula. Here's a snippet

        if (formula==43) {
                A=given[0]; // 30
                b=given[4]; // 25
                c=given[5]; // 40
                a =sqr(b^2 + c^2 - 2 * b * c * cos(A));
                echo ("line 56 ",A,B,C,a,b,c);

and the result of the echo is:
ECHO: "line 56 ", 30, 0, 0, 242999, 25, 40

The answer should be 22.20 according to the http://cossincalc.com
<http://cossincalc.com> site.

    nophead wrote
    If you mean sin to the -1 it means arcsine, which is asin() in
openscad.
    I.e. the inverse of sin.

    > What the heck does the '-1' in that formula mean?

Sent from the OpenSCAD mailing list archive
<http://forum.openscad.org/> at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad

Hmm... A= 30; b= 25; c= 40; a =sqr(b^2 + c^2 - 2 * b * c * cos(A)); echo ("line 56 ",A,B,C,a,b,c); ECHO: "line 56 ", 30, 0, 0, 242999, 25, 40 This is with OpenSCAD version 2021.04.21.ai7788 (git d9d4a9757) Exactly the same result with OpenSCAD version 2019.05 A= 30; b= 25; c= 40; a =sqr((b*b) + (c*c) - 2 * b * c * cos(A)); echo ("line 56 ",A,B,C,a,b,c); ECHO: "line 56 ", 30, 0, 0, 242999, 25, 40 I am unable to test with 2021.01 because on the OpenSCAD download page, sudo apt-get install openscad gives me 2019.05 mondo wrote >     A= 30; >                 b= 25; >                 c=  40; >                 a =sqrt(b^2 + c^2 - 2 * b * c * cos(A)); >                 echo ("line 56 ",A,B,C,a,b,c); > > works, I guess a given value is wrong. > > > On 10/05/2021 22:20, lar3ry wrote: >> Thanks! Got another problem with a formula. Here's a snippet >> >>         if (formula==43) { >>                 A=given[0]; // 30 >>                 b=given[4]; // 25 >>                 c=given[5]; // 40 >>                 a =sqr(b^2 + c^2 - 2 * b * c * cos(A)); >>                 echo ("line 56 ",A,B,C,a,b,c); >> >> and the result of the echo is: >> ECHO: "line 56 ", 30, 0, 0, 242999, 25, 40 >> >> The answer should be 22.20 according to the http://cossincalc.com >> &lt;http://cossincalc.com&gt; site. >> >>     nophead wrote >>     If you mean sin to the -1 it means arcsine, which is asin() in >> openscad. >>     I.e. the inverse of sin. >> >>     > What the heck does the '-1' in that formula mean? >> ------------------------------------------------------------------------ >> Sent from the OpenSCAD mailing list archive >> &lt;http://forum.openscad.org/&gt; at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to > discuss-leave@.openscad > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to > discuss-leave@.openscad -- Sent from: http://forum.openscad.org/
L
lar3ry
Mon, May 10, 2021 9:51 PM

That loud sound you just heard was my hand slapping my forehead!
Thanks Len!

LenStruttmann wrote

The square root function is sqrt().  You've got sqr().

That loud sound you just heard was my hand slapping my forehead! Thanks Len! LenStruttmann wrote > The square root function is sqrt(). You've got sqr(). -- Sent from: http://forum.openscad.org/