Function Set in OPEN CASCADE

Source: Internet
Author: User

Function Set in OPEN CASCADE

[Email protected]

Abstract. The common math algorithms library provides a C + + implementation of the most frequently used mathematical algorithms. These include:algorithms to solve a set of linear algebraic equations, algorithms to find the minimum of a function of E or more independent variables, algorithms to find roots of one, or of a set of non-linear equations, algorithm to find t He eigenvalues and eigenvectors of a square matrix. The Solver for function set are used widely in extrema value evaluation, point project on to curve and surface, also used T o Solve the point inverse for geometry curve and surface. The paper focus on the function is set concept and its solver in OPEN CASCADE.

Key Words. Function Set, Non-linear equation Solver, equations Root,

1. Introduction

The OPEN Cascade Math Package provides common numerical functions such as matrix subtraction, transpose and calculation of the eigenvalues and eigenvectors of matrices, solving linear equations, and calculating the differential, integral, and extreme values of a unary function or multivariate function; linear and nonlinear (non-linear Equations) equation set (function set) calculation and so on. Much of the functionality is similar to another open source Scientific computing library, GSL, and is easier to use with an object-oriented approach. The related computation of the equations (function set) is widely applied in the open Cascade library like the multivariate function (multivarfunction), such as some extremum calculation algorithms, the fitting method, the related problems of the point on the curved surface, etc. Will involve the calculation of solving equations. shown in the following class diagram.

The following class diagram is a class diagram of the class math_functionset of the equation group, which shows the number of classes derived from the class diagram, thus the importance of the open cascade. This article mainly explains its usage, and after understanding its usage, it is easy to understand other related algorithms.

After understanding most of the algorithms in the math package, it is also mastered a mathematical calculation tool, and later encountered related problems, can be as far as possible to solve the mathematical way, improve the level of application of mathematics.

Figure 1.1 Math_functionset class diagram in Opencascade

2. Function Set

Many scientific theories and engineering problems are eventually transformed into nonlinear equations or equations, such as the least squares method to be combined with the theoretical data or the experimental observation data, which is a typical problem of solving nonlinear equations. And the application in geometry is more extensive, such as calculating the intersection of straight line and plane, point to the projection problem of free curved surface and so on. In view of the wide application of the equations, an abstract class math_functionset is provided in the OPEN cascade Mathematical package to facilitate the calculation of the equations in the program.

For common equations, three abstract functions are mainly set up:

V Nbvariables (): The number of variables in the equation Group;

V Nbequations (): The number of equations in the equation Group;

V Value (): Calculates the value of the equation set for the specified variable;

The equations with differential systems are analogous to the two abstract functions of a common Equation group:

V Derivatives (): Calculates the differential value of the equation set of the specified variable;

V VALUES (): Calculates the values and differential values of the equations of the specified variable;

Because they are abstract classes, they cannot be used directly. According to the "calculation method" in the Book of the topic, to explain the equation set in the Opencascade calculation method. The following topics are from the second edition of calculation method P213 Page Example 17: A nonlinear equation set:

Geometrically, the solution is the intersection of circles and curves. The calculation code in Opencascade is given below:

/** Copyright (c) Shing Liu All rights reserved.** file:main.cpp* author:shing Liu (email Protected]) * date:2016-01-12 21:00* version:opencascade6.9.0** description:test function set.*/#defineWnt#include<math_FunctionSetRoot.hxx>#include<math_FunctionSetWithDerivatives.hxx>#pragmaComment (lib, "TKernel.lib")#pragmaComment (lib, "TKMath.lib")/** * @brief test function for a circle and a curve: * * F1 (X1,X2) = (x1) ^2 + (x2) ^2-4 * F2 (X1,X2) = e^ (x1) + x2-1 * * The derivatives of the function set is: * DX1F1 (X1,X2) = 2.0 * X1 * DX2F1 (X1,X2) = 2.0 * x2 * DX1F2 (X1,X2) = e^ (x 1) * DX2F2 (X1,X2) = 1.0*/classTest_functionset: Publicmath_functionsetwithderivatives{ Public:    VirtualStandard_integer Nbvariables ()Const    {        return 2; }    VirtualStandard_integer nbequations ()Const    {        return 2; }    VirtualStandard_boolean Value (Constmath_vector& X, math_vector&f) {f (1) = X (1) * X (1) + X (2) * X (2) -4.0; F (2) = exp (X (1)) + X (2) -1.0; returnstandard_true; }    VirtualStandard_boolean Derivatives (Constmath_vector& X, math_matrix&d) {d (1,1) =2.0X1); D (1,2) =2.0X2); D (2,1) = exp (X (1)); D (2,2) =1.0; returnstandard_true; }    VirtualStandard_boolean Values (Constmath_vector& X, math_vector& F, math_matrix&D) {Value (X, F);        Derivatives (X, D); returnstandard_true; }};voidTestfunctionset (void) {Test_functionset atestfunctionset;    Math_functionsetroot Asolver (Atestfunctionset); Math_vector Astartpoint (1,2,0.0); //Initial guess point ( -2.0, 0.0)Astartpoint (1) = -2.0; Astartpoint (2) =0.0;    Asolver.perform (Atestfunctionset, astartpoint); Std::cout<< Asolver <<Std::endl; //Initial guess point (0.0, -2.0)Astartpoint (1) =0.0; Astartpoint (2) = -2.0;    Asolver.perform (Atestfunctionset, astartpoint); Std::cout<< Asolver <<Std::endl;}intMainintargcChar*argv[])    {Testfunctionset (); return 0;}

The calculation results are as follows:

Figure 2.1 Evaluate Result

3. Application

The algorithms for solving equations are used in the calculation of extreme values of curves and surfaces, in the calculation of extreme values of surfaces and surfaces, and in the calculation of extreme values of points and surfaces, as shown in the following class diagram:

Figure 3.1 Extrema algorithms implemented by Function Set

The calculation of the extremum of point and surface is also applicable to the inverse of the parameters of the point on the surface. Similar to the parameters of the point on the curve, the parameters of the points on the curve are reversed to calculate the root of the nonlinear equation, and the inverse of the parameters of the points on the surface expands to the nonlinear equations. The key to solving the problem is to build a mathematical model, such as a projection on a point-to-curve:

Figure 3.2 Point project on Curve

The constructed functions are:

The upper line indicates that the tangent of the parameter U on the curve and the point of the parameter U on the curve are the quantity product of the vector at the specified point, when f (U) =0 The quantity product is 0, that is, the point perpendicular to the curve on the tangent of the parameter u, to solve the nonlinear equation, the point to the curve projection. Similarly, a point-to-surface projection can also create a similar set of equations:

The partial derivative of the curved face parameter u,v the tangent of the surface in the u,v direction, and the two function meaning is similar to the meaning of an equation, that is, the quantity product of the vector and tangent point to a certain spot on the surface. When the number of vectors and two tangent directions is 0, that is, the vector is perpendicular to both tangents, which is the projection of the point to the surface. This is also the implementation of the compute point and surface extremum in open cascade, whose class is Extrema_funcextps, in order to solve the equations using class Math_functionsetroot, Extrema_funcextps is also by class Math_ Functionsetwithderivatives derived, the class definition code is as follows:

//! Functional for search of extremum of the distance between point P and//surface S, starting from approximate solution (u0, v0).//!//! The class inherits math_functionsetwithderivatives and thus is intended//math_functionsetroot algorithm.//!//! Denoting derivatives of the surface S (u,v) by U and V, respectively, as//! Su and Sv, the both functions to is nullified are://!//! F1 (u,v) = (s-p) * Su//! F2 (u,v) = (s-p) * Sv//!//! The derivatives of the functional are://!//! DUF1 (u,v) = su^2 + (s-p) * SUU;//! DVF1 (U,V) = Su * Sv + (s-p) * Suv//! DUF2 (U,V) = Sv * Su + (s-p) * Suv = Dvf1//! DVF2 (u,v) = sv^2 + (s-p) * SVV//!//! Here * denotes scalar product, and ^2 is square power.classExtrema_funcextps: Publicmath_functionsetwithderivatives{ Public: Define_standard_alloc standard_export Extrema_funcextps (); Standard_export Extrema_funcextps (Constgp_pnt& P,Constadaptor3d_surface&S); //! Sets the field mysurf of the function.Standard_exportvoidInitialize (Constadaptor3d_surface&S); //! Sets the field mysurf of the function.Standard_exportvoidSetPoint (Constgp_pnt&P); Standard_export Standard_integer nbvariables ()ConstStandard_override; Standard_export Standard_integer nbequations ()ConstStandard_override; //! Calculate Fi (u,v).Standard_export Standard_boolean Value (Constmath_vector& UV, math_vector&F) Standard_override; //! Calculate Fi ' (u,v).Standard_export Standard_boolean Derivatives (Constmath_vector& UV, math_matrix&DF)    Standard_override; //! Calculate Fi (u,v) and fi ' (u,v).Standard_export Standard_boolean Values (Constmath_vector& UV, math_vector& F, math_matrix&DF)    Standard_override; //! Save the found extremum.Standard_exportVirtualStandard_integer getstatenumber () standard_override; //! Return the number of found extrema.Standard_export Standard_integer Nbext ()Const; //! Return the value of the Nth distance.Standard_export Standard_real Squaredistance (ConstStandard_integer N)Const; //! Returns the Nth extremum.Standard_exportConstextrema_ponsurf& Point (ConstStandard_integer N)Const;protected:Private: Gp_pnt MyP;  Adaptor3d_surfaceptr MyS;  Standard_real Myu;  Standard_real MyV;  GP_PNT Myps;  Tcolstd_sequenceofreal mysqdist;  Extrema_sequenceofponsurf MyPoint;  Standard_boolean Mypinit; Standard_boolean Mysinit;};

According to its annotations, the equations set up are the same as the above equations, and the first derivative of the equations is calculated as follows:

The extremum of point to surface can be obtained by solving the above equations by class Math_functionsetroot.

4. Conclusion

The solution of linear and nonlinear equations has a lot of applications in geometry. Linear equations can be solved by using the concept of matrix, such as Gauss elimination method. But the solution of non-linear equations is also related to the algorithm, such as Newton method, concrete theory can refer to the "calculation method" and other related books. After mastering these mathematical tools, the key is to abstract geometric problems into mathematical problems, and then use these mathematical tools to solve practical problems. Therefore, "higher mathematics", "linear algebra" and other theoretical knowledge, through the "computational method" in the computer implementation, to use the theory to guide the practice, through practice to deepen the understanding of the theory. It also makes the boring theory more vivid and interesting.

As with other concepts such as meta-functions and multivariate functions in the Open Cascade Math package, nonlinear equations and their solutions are also an important concept. After understanding the principles of these classes, it is easy to understand the implementation principles of other geometric modeling algorithms.

5. References

1. Zhao, Moux, Wang La translation. Non-uniform rational B-spline. Tsinghua University Press. 1995

2. Easy righteousness, Chen Daoqi. Introduction to numerical analysis. Zhejiang University Press. 1998

3. Easy righteousness, Shen Yunbao, Li Youfa. Calculation method. Zhejiang University Press. 2002

4. Sing, Zhao Scenery, Su Yifeng. Numerical approximation. Fudan University Press. 2012

5. Renhong, Li Chongjun, Chunquan Zhu Steel. Computational Geometry tutorial. Science Press. 2008

6. Department of Mathematics, Tongji University. Advanced mathematics. Higher Education Press. 1996

7. Department of Applied Mathematics, Tongji University. Linear algebra. Higher Education Press. 2003

PDF version:function Set in OPEN CASCADE

Function Set in OPEN CASCADE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.