Documenting Vector, Matrix, Rotation & Placement Expressions

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
gbroques
Posts: 167
Joined: Thu Jan 23, 2020 3:28 am
Location: St. Louis, Missouri

Documenting Vector, Matrix, Rotation & Placement Expressions

Post by gbroques »

I just found out all of these are available in Expressions & Spreadsheets:

https://github.com/FreeCAD/FreeCAD/blob ... #L873-L945

Is this documented somewhere on the Wiki already?

If not, is the Expressions page where you would expect to find this information?

I'm offering to document this somewhere, but wanted to have a quick discussion on the forum first.

Create

Function arguments are delimited by a semi-colon (";").
  • Create a vector - create(<<vector>>; 2; 1; 2)
  • Create a matrix - create(<<matrix>>; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0)
  • Create a rotation - create(<<rotation>>; create(<<vector>>; 0; 1; 0); 45)
  • Create a placement - create(<<placement>>; create(<<vector>>; 2; 1; 2); create(<<rotation>>, create(<<vector>>, 0, 1, 0), 45))
  • Create a tuple - tuple(2; 1; 2)
  • Create a list - list(2; 1; 2)
Mathematical Operations
Various mathematical operations with the above structures are supported through standard mathematical operators such as:
  • ^ - to raise to a power
  • * - to multiply two entities
Mathematical Functions
  • mscale - scale a matrix
  • minvert - invert a matrix

Full List of Functions in Source Code:
https://github.com/FreeCAD/FreeCAD/blob ... 2350-L2436

Full List of Create Types in Source Code:
https://github.com/FreeCAD/FreeCAD/blob ... 2077-L2086
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by TheMarkster »

I thought I had seen them documented somewhere, but maybe not. I think the Expressions page is a good place to put them.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by chrisb »

The first of these can well go to the Placement page.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
M4x
Veteran
Posts: 1472
Joined: Sat Mar 11, 2017 9:23 am
Location: Germany

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by M4x »

Some mathematical functions can be found here:
Expressions#General_mathematical_functions

But the list isn't complete. Max is missing for example.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by chrisb »

M4x wrote: Mon Oct 18, 2021 7:21 am Max is missing
Max is busy in the forum (couldn't resist :P ).
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by Roy_043 »

M4x wrote: Mon Oct 18, 2021 7:21 am Max is missing for example.
No, it is documented. Look at "Statistical / aggregate functions".
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by Roy_043 »

gbroques wrote: Sun Oct 17, 2021 10:13 pm ^ - to raise to a power
* - to multiply two entities
Also already documented.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by adrianinsaval »

chrisb wrote: Mon Oct 18, 2021 5:29 am The first of these can well go to the Placement page.
the expression page is more appropiate IMO
User avatar
gbroques
Posts: 167
Joined: Thu Jan 23, 2020 3:28 am
Location: St. Louis, Missouri

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by gbroques »

chrisb wrote: Mon Oct 18, 2021 5:29 am The first of these can well go to the Placement page.
Thanks! I'll make a link or note to see the Expressions page in the "Using Placement in expressions" section on the Placement page.

I'd rather not duplicate this information on the Wiki.

Roy_043 wrote: Mon Oct 18, 2021 12:15 pm
gbroques wrote: Sun Oct 17, 2021 10:13 pm ^ - to raise to a power
* - to multiply two entities
Also already documented.
I wanted to make explicit mention that these operations (e.g. multiplication, addition, subtraction) are supported with these entites like vectors, matrices, rotations, and placements in expressions.

However, maybe that's clear enough from the existing documentation.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Documenting Vector, Matrix, Rotation & Placement Expressions

Post by chrisb »

adrianinsaval wrote: Mon Oct 18, 2021 12:46 pm the expression page is more appropiate IMO
Then go for it.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply