mirror of https://github.com/rusefi/bldc.git
Added more math functions
This commit is contained in:
parent
2113339cfa
commit
c6dedf173b
|
@ -522,19 +522,40 @@ Get the sine of angle. Unit: Radians.
|
|||
|
||||
Get the cosine of angle. Unit: Radians.
|
||||
|
||||
#### tan
|
||||
```clj
|
||||
(tan angle)
|
||||
```
|
||||
|
||||
Get the tangent of angle. Unit: Radians.
|
||||
|
||||
#### asin
|
||||
```clj
|
||||
(asin x)
|
||||
```
|
||||
|
||||
Get the arc sine of x. Unit: Radians.
|
||||
|
||||
#### acos
|
||||
```clj
|
||||
(acos x)
|
||||
```
|
||||
|
||||
Get the arc cosine of x. Unit: Radians.
|
||||
|
||||
#### atan
|
||||
```clj
|
||||
(atan x)
|
||||
```
|
||||
|
||||
Get the arctangent of x. Unit: Radians.
|
||||
Get the arc tangent of x. Unit: Radians.
|
||||
|
||||
#### atan2
|
||||
```clj
|
||||
(atan2 y x)
|
||||
```
|
||||
|
||||
Get the arctangent of y / x. Unit: Radians. This is the version that uses two arguments.
|
||||
Get the arc tangent of y / x. Unit: Radians. This version uses the signs of y and x to determine the quadrant.
|
||||
|
||||
#### pow
|
||||
```clj
|
||||
|
@ -550,6 +571,20 @@ Get base raised to power.
|
|||
|
||||
Get the square root of x.
|
||||
|
||||
#### log
|
||||
```clj
|
||||
(log x)
|
||||
```
|
||||
|
||||
Get the base-e logarithm of x.
|
||||
|
||||
#### log10
|
||||
```clj
|
||||
(log10 x)
|
||||
```
|
||||
|
||||
Get the base-10 logarithm of x.
|
||||
|
||||
### Bit Operations
|
||||
|
||||
#### bits-enc-int
|
||||
|
|
|
@ -756,6 +756,21 @@ static lbm_value ext_cos(lbm_value *args, lbm_uint argn) {
|
|||
return lbm_enc_F(cosf(lbm_dec_as_f(args[0])));
|
||||
}
|
||||
|
||||
static lbm_value ext_tan(lbm_value *args, lbm_uint argn) {
|
||||
CHECK_ARGN_NUMBER(1)
|
||||
return lbm_enc_F(tanf(lbm_dec_as_f(args[0])));
|
||||
}
|
||||
|
||||
static lbm_value ext_asin(lbm_value *args, lbm_uint argn) {
|
||||
CHECK_ARGN_NUMBER(1)
|
||||
return lbm_enc_F(asinf(lbm_dec_as_f(args[0])));
|
||||
}
|
||||
|
||||
static lbm_value ext_acos(lbm_value *args, lbm_uint argn) {
|
||||
CHECK_ARGN_NUMBER(1)
|
||||
return lbm_enc_F(acosf(lbm_dec_as_f(args[0])));
|
||||
}
|
||||
|
||||
static lbm_value ext_atan(lbm_value *args, lbm_uint argn) {
|
||||
CHECK_ARGN_NUMBER(1)
|
||||
return lbm_enc_F(atanf(lbm_dec_as_f(args[0])));
|
||||
|
@ -776,6 +791,16 @@ static lbm_value ext_sqrt(lbm_value *args, lbm_uint argn) {
|
|||
return lbm_enc_F(sqrtf(lbm_dec_as_f(args[0])));
|
||||
}
|
||||
|
||||
static lbm_value ext_log(lbm_value *args, lbm_uint argn) {
|
||||
CHECK_ARGN_NUMBER(1)
|
||||
return lbm_enc_F(logf(lbm_dec_as_f(args[0])));
|
||||
}
|
||||
|
||||
static lbm_value ext_log10(lbm_value *args, lbm_uint argn) {
|
||||
CHECK_ARGN_NUMBER(1)
|
||||
return lbm_enc_F(log10f(lbm_dec_as_f(args[0])));
|
||||
}
|
||||
|
||||
// Bit operations
|
||||
|
||||
/*
|
||||
|
@ -1181,10 +1206,15 @@ void lispif_load_vesc_extensions(void) {
|
|||
// Math
|
||||
lbm_add_extension("sin", ext_sin);
|
||||
lbm_add_extension("cos", ext_cos);
|
||||
lbm_add_extension("tan", ext_tan);
|
||||
lbm_add_extension("asin", ext_asin);
|
||||
lbm_add_extension("acos", ext_acos);
|
||||
lbm_add_extension("atan", ext_atan);
|
||||
lbm_add_extension("atan2", ext_atan2);
|
||||
lbm_add_extension("pow", ext_pow);
|
||||
lbm_add_extension("sqrt", ext_sqrt);
|
||||
lbm_add_extension("log", ext_log);
|
||||
lbm_add_extension("log10", ext_log10);
|
||||
|
||||
// Bit operations
|
||||
lbm_add_extension("bits-enc-int", ext_bits_enc_int);
|
||||
|
|
Loading…
Reference in New Issue