mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 13:34:10 +00:00
Add cross_product example to documentation (#665)
* Cross_Product Example * Update cross_product - Removes the first empty line - Uses doxygen commands - Adds result at the end as comments - Mentions that the second point is undefined in Example 1 * Update Cross_Product - Added a missing ` * Update imports.qbk - Adds [import src/examples/arithmetic/cross_product.cpp] * Create cross_product.qbk * Update cross_product.hpp Refers cross_product example * Delete cross_product.qbk Uneccessary * Update Deletes .qbk reference * Update make_qbk.py * Rename cross_product to cross_product.cpp * Update -Shifts example reference to line 115-116 Co-authored-by: Vissarion Fisikopoulos <fisikop@gmail.com>
This commit is contained in:
parent
664f984bca
commit
a4f08ea191
@ -85,6 +85,7 @@
|
||||
[import src/examples/algorithms/unique.cpp]
|
||||
[import src/examples/algorithms/within.cpp]
|
||||
|
||||
[import src/examples/arithmetic/cross_product.cpp]
|
||||
[import src/examples/arithmetic/dot_product.cpp]
|
||||
|
||||
[import src/examples/core/coordinate_type.cpp]
|
||||
|
@ -106,6 +106,8 @@ algorithms = ["append", "assign", "make", "clear"
|
||||
, "relation", "reverse","simplify", "sym_difference", "touches"
|
||||
, "transform", "union", "unique", "within"]
|
||||
|
||||
arithmetic = ["cross_product"]
|
||||
|
||||
access_functions = ["get", "set", "exterior_ring", "interior_rings"
|
||||
, "num_points", "num_interior_rings", "num_geometries"]
|
||||
|
||||
|
57
doc/src/examples/arithmetic/cross_product.cpp
Normal file
57
doc/src/examples/arithmetic/cross_product.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
// Boost.Geometry
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2020, Aditya Mohan
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[cross_product
|
||||
//` Calculate the cross product of two points
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/arithmetic/cross_product.hpp>
|
||||
|
||||
namespace bg = boost::geometry; /*< Convenient namespace alias >*/
|
||||
|
||||
int main()
|
||||
{
|
||||
//Example 1 2D Vector
|
||||
|
||||
bg::model::point<double, 2, bg::cs::cartesian> p1(7.0, 2.0);
|
||||
bg::model::point<double, 2, bg::cs::cartesian> p2(4.0, 5.0);
|
||||
|
||||
bg::model::point<double, 2, bg::cs::cartesian> r1;
|
||||
|
||||
r1 = bg::cross_product(p1,p2);
|
||||
|
||||
std::cout << "Cross Product 1: "<< r1.get<0>() << std::endl; //Note that the second point (r1.get<1>) would be undefined in this case
|
||||
|
||||
//Example 2 - 3D Vector
|
||||
|
||||
bg::model::point<double, 3, bg::cs::cartesian> p3(4.0, 6.0, 5.0);
|
||||
bg::model::point<double, 3, bg::cs::cartesian> p4(7.0, 2.0, 3.0);
|
||||
|
||||
bg::model::point<double, 3, bg::cs::cartesian> r2;
|
||||
|
||||
r2 = bg::cross_product(p3,p4);
|
||||
|
||||
std::cout << "Cross Product 2: ("<< r2.get<0>() <<","<< r2.get<1>() <<","<< r2.get<2>() << ")"<< std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
//[cross_product_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
Cross Product 1: 27
|
||||
Cross Product 2: (8,23,-34)
|
||||
]
|
||||
*/
|
||||
//]
|
@ -90,7 +90,8 @@ struct cross_product<3>
|
||||
\param p1 first vector
|
||||
\param p2 second vector
|
||||
\return the cross product vector
|
||||
*/
|
||||
|
||||
*/
|
||||
template <typename ResultP, typename P1, typename P2>
|
||||
inline ResultP cross_product(P1 const& p1, P2 const& p2)
|
||||
{
|
||||
@ -110,6 +111,9 @@ inline ResultP cross_product(P1 const& p1, P2 const& p2)
|
||||
\param p1 first vector
|
||||
\param p2 second vector
|
||||
\return the cross product vector
|
||||
|
||||
\qbk{[heading Examples]}
|
||||
\qbk{[cross_product] [cross_product_output]}
|
||||
*/
|
||||
template <typename P>
|
||||
inline P cross_product(P const& p1, P const& p2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user