2019-01-24

Trigonometric Identities

Phase rotation table of sin and cos


fi [rad]fi [deg]cos(x+fi)sin(x+fi)cos(fi-x)sin(fi-x)

-pi-180-cos(x)-sin(x)-cos(x)sin(x)

-pi/2-90sin(x)-cos(x)-sin(x)-cos(x)

00cos(x)sin(x)cos(x)-sin(x)

+pi/290-sin(x)cos(x)sin(x)cos(x)

+pi180-cos(x)-sin(x)-cos(x)sin(x)
















C++ Inheritance

Inheritance is a feature in which you can have a class inherit variables and methods from another class without writing them over and over from scratch.

operator ":" is used to specify inheritance

In the class header you inherit the definition
Derived : Parent

The derived constructor will call the default parent constructor if you declare the constructor naked. Same for the destructor.

it is possible for the derived constructor to call the initialized parent constructor with the operator ":" in the implementation.

The parent constructor will be called BEFORE the derived constructor.
The parent destructor will be called AFTER the derived destructor.

This is valid for methods as well. You can have two methods with the same name in derived and parent class, and the derived implementation will be favored.

Example.
In your program you need to handle humans and students.
Humans have several characteristics. Name, age and gender.
Students have several characteristics. Name, age, gender and id.

Student has all the characteristics of a human with some additions.
Inheritance allows the class student to inherit all the variables and methods from the class human while adding some that are unique to the class student.

Full code

First I define the parent class with header and implementation.
Parent Class Header

XXX

Parent Class Implementation
XXX

With this I defined the class human with the characteristics Name, age and gender.

Now to Make the class student I can Inherit Name, age and gender from the parent class human, while adding just variables and handler for the last characteristic the id which is unique to the Derived class

Derived Class Header
END

Derived Class Implementation
END


2019-01-23

QT Signals Slots


Signals and slots are like direct links. It's an event system where a signal will pass its arguments to the connected slot. It's similar to python and probably the most peculiar feature of QT.

The Signal slots paradigm makes GUI desing a lot simpler. Something happens->do something else. They are also thread safe for good measure.

Internally QT will translate signals slots and connect in real C++ code in meta C++ files before the real compilation begins.

Here I added a slot to the main class. It's a public method with a macro definition used by QT for his translation into real C++ code.

class MainWindow : public QMainWindow
{
    Q_OBJECT

    public:
        explicit MainWindow(QWidget *parent = nullptr);
        ~MainWindow();

    public Q_SLOTS:
        void txt_update( int num );

    private:
        Ui::MainWindow *ui;
};




The slots take care of writing an integer inside a line control

void MainWindow::txt_update( int num )
{
    User::Qt_utils::qline_show_int( ui ->txt, num );
}
I have an object with a signal. The signal too is public and declared as macro.


class Sender : public QObject
{
    Q_OBJECT

    public:
        Sender();

    Q_SIGNALS:
        void send( int num );
};
Here is the code inside the constructor of the main window.
I create the sender object.
I call directly the slot to update the control and initialize it.
I connect the sender output with the slot input.
I call the sender object which will pass it's argument to the slot automagically!
//I can call a slot directly //This slot is set to update the txt control wint an integer when called this -> txt_update( 0 ); //QT will actually add more c++ files to handle signals and slots in real C++ code //Connect the signal coming from the sender class to the slot of the Main Window class //singal and slot must have same arguments in this style of connect connect ( &my_tx, //Reference to source signal object &Sender::send, //Reference to the source signal method. It's just the definition and it's not tied to the individual object. this, //Reference to the dest slot object. In this case I use the current class instance &MainWindow::txt_update //Reference to the dest slot method. It's just the definition and it's not tied to the individual object. ); //I can send a signal by simply calling the method directly //This will cause the slot of the main class to be activated with the same argument of the sender signal my_tx.send( 17 );

QT Add a new Kit


Create a new compiler with the binaries

This is the easy part.
ABI is not functional, is just used to sign the compiler and for QT to detect inconsistencies.




Here is where things get hard
QMAKE create a makefile. It uses .pro and a configuration file stored in the mkspec folder of the QT kit to configure everything. You need QMAKE.CONF and QPLATFORMDEFS.H configured properly for everything to works and for the makefile to be done the right way.


QT needs to be built USING the kit compiler in order to generate all the QT dll.
Those .dll are required for the binary to work and have to be bundled with the application.
STATIC:
Creating a static application with QT is a nightmare. In order to do it you need static libs, not dinamic link libraries, and to do so you need to recompile QT the right way with the right compiler to generate them.
After that you need to configure the kit to make a static compilation.









TOOLCHAIN

“Shadow built” is used to output in a folder different from the source project
“qmake” is the command line that is effectively being executed to create the makefile
“make” is used to call the compiler with all dependencies and generate the binaries
“Build environment” is used to add the paths required to build, like the compiler include and lib folders, the compiler binaries, etc...
The hardest thing to do is to configure QMAKE to generate the makefile the right way with all dependencies.

KITS

This is the final thing that ties all together
“File System Name” is useless
“Sysroot” is used to specify the system libraries. Works without but results in the binary duplicating some dependency/library.
“Compiler” is the one specified in the compiler slide
“QT Version” specifies the binaries and QT dll to use. If you target arm you need the QT dll compiled for arm to bundle with the binary for it to work
Qt mkspec is where the configuration file used by qmake to generate the makefile lay

DEPLOY

To deploy an application so that it can be executed without the QT toolchain you need to bundle in all the .dll dependencies.
The easiest way to do so is to execute and bring in the .dll that causes trouble.
Take care to bundle the right .dll. One compiled for another architecture, or with the right architecture but the wrong compiler won't work. You can find the .dll of QT here:
Each kit in the /bin folder has all the .dll compiled with the kit. You need to bundle them with the executable of your project or setup a system variable to tell where to find them.

2019-01-22

Unit of Measures



Sheet 1: Unit Measures





Unit SI SI+N SI+V SI+W SI+J

Distance Meter m m




Mass Kilogram Kg Kg




Time Second s s




Current Ampere A A




Speed

m/s




Acceleration

m/s2




Jerk

m/s3



Force[N]=mass[Kilograms]*Acceleration[m/s2] Force Newton N Kg*m/s2



Energy[J]=Torque[N*m]*Angle[rad] Torque

Kg*m2/s2 N*m/rad

J/rad










Charge Coulomb C A*s



Voltage[V]=Power[Kg*m2/s2]/Current[A] Voltage Volt V Kg*m2/s2/A




Angular Inertia J
Kg*m2




Capacitance Farad F s4*A2/m2/Kg
A*s/V


Inductance Henry H Kg*m2/s2/A2
V*s/A
J/A2
Electric Field[V/m]=Voltage[V]/Distance[m] Electric Field E
Kg*m/A/s3
V/m


Magnetic Field Tesla T Kg/A/s2 N/A/m V*s/m2
J/A/m2









Energy[J]=Force[N]*Displacement[m] Energy Joule J Kg*m2/s2 N*m


Energy[J]=int{Power[W]*dt[S]} Energy Joule J


W*s
Energy[J]=0.5*Voltage[V]^2*Capacitance[F]







Energy[J]=0.5*Current[A]^2*Inductance[H]







Energy[J] = electrostatic permeattivity[F/m] *Electric field[V/m]^2 *volume[m3]







Energy[J] = 1/magnetic permeability[H/m] *Magnetic Field[T]^2 *volume[m3]







Power[W]=Voltage[V]*Current[A] Power Watt W Kg*m2/s2
V*A

Power Power Watt W

V*A











Volumetric Density ro Kg/m3





Charge Density ro_q C/m3





Current Density J A/m2














Resistence Ohm Ohm Kg*m2/s3/A2
V/A




























Magnetic Field [T] = magnetic constant [H/m] *Current[A] /2pi /Distance[m]







Force[N] = Length[m] * Current [A] x Magnetic Field [T]