Area of Parallelogram

We can get the third vector by cross product of two vectors, the new vector is perpendicular to the first vectors.
The length of the third vector is equal to the area of the parallelogram formed by \overrightarrow{u} and \overrightarrow{v}. But it’s a signed result for area.

\Vert\overrightarrow{u}\times\overrightarrow{v}\Vert =Area(\overrightarrow{u}\times\overrightarrow{v})=\Vert\overrightarrow{u}\Vert \Vert\overrightarrow{v}\Vert sin\theta


#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/number_utils.h>
#include <iostream>
#include <cmath>

using namespace std;

typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef K::Point_3 Point;
typedef K::Vector_3 Vector;

int main()
{
    CGAL::set_mode( cout, CGAL::IO::PRETTY );
    Vector U( Point(0, 0, 0 ), Point(2, 0, 0) );
    Vector V( Point(0, 0, 0 ), Point(3, 2, 0) );
    Vector W = CGAL::cross_product( U, V );
    auto tmp = W.squared_length(); // cpp11::result_of<typename R::Compute_square...>
    auto value = tmp.exact().get_d();
    double result = CGAL::sqrt( value );
    cout << result << endl;
    return 0;
}

Output:

4

Volume Of Triple Vectors

The volume of the vectors \overrightarrow{u}, \overrightarrow{v}, and \overrightarrow{w} can be calculated by determinant.



We need to use dot product and cross product in the process.

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/number_utils.h>
#include <iostream>
#include <cmath>

using namespace std;

typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef K::Point_3 Point;
typedef K::Vector_3 Vector;

int main()
{
    CGAL::set_mode( cout, CGAL::IO::PRETTY );
    Vector U( Point(0, 0, 0 ), Point(2, 2, 0) );
    Vector V( Point(0, 0, 0 ), Point(4, 0, 0) );
    Vector W( Point(0, 0, 0 ), Point(2, 2, 4) );
    auto tmp = CGAL::cross_product( U, V ) * W;

    tmp = CGAL::abs( tmp.exact() );
    cout << tmp << endl;
    return 0;
}

Output:

32

We also know the geometry meaning of the determinant, it’s sign volumn value for three vectors.
Vol(\overrightarrow{u}, \overrightarrow{v}, \overrightarrow{w})=\vert det(\overrightarrow{u}, \overrightarrow{v}, \overrightarrow{w})\vert

So we can calculate the area by determinant.

    auto tmp = CGAL::determinant( U, V, W );
    tmp = CGAL::abs( tmp.exact() );
    cout << tmp << endl;
Categories: CGALMath

0 0 votes
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] The angle between two vectors can be calculated by the dot product. We want to find the direction of the rotation. Here are two different ways to get it done. 1. Compute the value of Sine of the angle, then we can judge it’s clockwise or counterclockwise. The value of Sine of the angle can be calculated by the signed area of the parallelogram formed by the two vectors. Relative post: CGAL: Area of Parallelogram And Volume Of Triple Vectors […]

3D Model Viewer: add grid plane and convex hull.
Add google translate tool at right-bottom position.

X
A prohibited operation
1
0
Would love your thoughts, please comment.x
()
x