OpenCASCADE Trihedron Law

eryar@163.com

Abstract. In differential geometry the Frenet-Serret formulas describe the kinematic properties of a particle moving along a continuous, differentiable curve in 3d space, or the geometric properties of the curve itself irrespective of any motion. More specifically, the formulas describe the derivatives of the so-called Tangent, Normal and Binormal unit vectors in terms of each other.

Key Words. Frenet-Serret Frame, TNB frame, Trihedron Law

1. Introduction

参数曲线上的局部坐标系,也称为标架Frame,OpenCASCADE中叫Trihedron。这个局部坐标系随着曲线上点的运动而运动,所以也称为活动坐标系。活动坐标系中各坐标轴的选取:

l T是参数曲线的切线方向;

l N是曲线的主法线方向,或称主法矢;主法矢总是指向曲线凹入的方向;

l B是副法矢;当T 和N确定后,通过叉乘即得到B。

Figure 1. T, N, B frame of a curve (from wiki)

定义一个活动标架有什么作用呢?把这个问题先保留一下。本文先介绍OpenCASCADE中的标架规则Trihedron Law。

2.Trihedron Law

在OpenCASCADE中,类GeomFill_TrihedronLaw定义了曲线活动标架。其类图如下所示:

Figure 2. Trihedron Law define Trihedron along a Curve

从基类GeomFill_TrihedronLaw派生出了各种标架,如:

l GeomFill_Fixed:固定的活动动标架,即标架沿着曲线移动时,标架的三个方向是固定的;

l GeomFill_Frenet: Frenet标架;

l GeomFill_Darboux :Darboux标架;

l GeomFill_ConstantBiNormal:副法矢固定的标架;

3. Code Demo

下面通过示例代码来显示出曲线上的Frenet标架,GeomFill_TrihedronLaw子类的用法类似。

/*
Copyright(C) 2018 Shing Liu(eryar@163.com) Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions : The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/ #include <TColgp_Array1OfPnt.hxx> #include <math_BullardGenerator.hxx> #include <GCPnts_UniformAbscissa.hxx>
#include <GCPnts_UniformDeflection.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#include <GCPnts_QuasiUniformDeflection.hxx> #include <Geom_BSplineCurve.hxx> #include <GeomAdaptor_HCurve.hxx> #include <GeomAPI_PointsToBSpline.hxx> #include <GeomFill_Fixed.hxx>
#include <GeomFill_Frenet.hxx>
#include <GeomFill_ConstantBiNormal.hxx>
#include <GeomFill_CorrectedFrenet.hxx>
#include <GeomFill_Darboux.hxx>
#include <GeomFill_DiscreteTrihedron.hxx>
#include <GeomFill_GuideTrihedronAC.hxx>
#include <GeomFill_GuideTrihedronPlan.hxx> #include <BRepBuilderAPI_MakeEdge.hxx> #include <BRepTools.hxx> #pragma comment(lib, "TKernel.lib")
#pragma comment(lib, "TKMath.lib") #pragma comment(lib, "TKG2d.lib")
#pragma comment(lib, "TKG3d.lib")
#pragma comment(lib, "TKGeomBase.lib")
#pragma comment(lib, "TKGeomAlgo.lib") #pragma comment(lib, "TKBRep.lib")
#pragma comment(lib, "TKTopAlgo.lib") void test()
{
TColgp_Array1OfPnt aPoints(, );
math_BullardGenerator aBullardGenerator;
for (Standard_Integer i = aPoints.Lower(); i <= aPoints.Upper(); ++i)
{
Standard_Real aX = aBullardGenerator.NextReal() * 50.0;
Standard_Real aY = aBullardGenerator.NextReal() * 50.0;
Standard_Real aZ = aBullardGenerator.NextReal() * 50.0; aPoints.SetValue(i, gp_Pnt(aX, aY, aZ));
} GeomAPI_PointsToBSpline aBSplineFitter(aPoints);
if (!aBSplineFitter.IsDone())
{
return;
} std::ofstream aTclFile("d:/tcl/trihedron.tcl"); aTclFile << std::fixed;
aTclFile << "vclear" << std::endl; Handle(Geom_BSplineCurve) aBSplineCurve = aBSplineFitter.Curve();
Handle(GeomAdaptor_HCurve) aCurveAdaptor = new GeomAdaptor_HCurve(aBSplineCurve); BRepBuilderAPI_MakeEdge anEdgeMaker(aBSplineCurve);
BRepTools::Write(anEdgeMaker, "d:/edge.brep"); aTclFile << "restore " << " d:/edge.brep e" << std::endl;
aTclFile << "incmesh e " << " 0.01" << std::endl;
aTclFile << "vdisplay e " << std::endl; Handle(GeomFill_Frenet) aFrenet = new GeomFill_Frenet();
aFrenet->SetCurve(aCurveAdaptor); GCPnts_UniformAbscissa aPointSampler(aCurveAdaptor->Curve(), 5.0);
for (Standard_Integer i = ; i <= aPointSampler.NbPoints(); ++i)
{
Standard_Real aParam = aPointSampler.Parameter(i);
gp_Pnt aP = aCurveAdaptor->Value(aParam); gp_Vec aT;
gp_Vec aN;
gp_Vec aB; aFrenet->D0(aParam, aT, aN, aB); // vtrihedron in opencascade draw 6.9.1
/*aTclFile << "vtrihedron vt" << i << " " << aP.X() << " " << aP.Y() << " " << aP.Z() << " "
<< " " << aB.X() << " " << aB.Y() << " " << aB.Z() << " "
<< " " << aT.X() << " " << aT.Y() << " " << aT.Z() << std::endl;*/ // vtrihedron in opencascade draw 7.1.0 has bug.
/*aTclFile << "vtrihedron vt" << i << " -origin " << aP.X() << " " << aP.Y() << " " << aP.Z() << " "
<< " -zaxis " << aB.X() << " " << aB.Y() << " " << aB.Z() << " "
<< " -xaxis " << aT.X() << " " << aT.Y() << " " << aT.Z() << std::endl;*/ // vtrihedron in opencascade draw 7.2.0
aTclFile << "vtrihedron vt" << i << " -origin " << aP.X() << " " << aP.Y() << " " << aP.Z() << " "
<< " -zaxis " << aB.X() << " " << aB.Y() << " " << aB.Z() << " "
<< " -xaxis " << aT.X() << " " << aT.Y() << " " << aT.Z() << std::endl;
aTclFile << "vtrihedron vt" << i << " -labels xaxis T 1" << std::endl;
aTclFile << "vtrihedron vt" << i << " -labels yaxis N 1" << std::endl;
aTclFile << "vtrihedron vt" << i << " -labels zaxis B 1" << std::endl; aTclFile << "vsize vt" << i << "" << std::endl;
}
} int main(int argc, char* argv[])
{
test(); return ;
}

程序通过拟合几个随机产生的点生成B样条曲线,再将曲线按弧长等距采样,将得到的参数计算出曲线上的点,及Frenet标架。再生成Draw脚本文件,最后将生成的Draw脚本文件trihedron.tcl加载到Draw Test Harness中显示结果如下图所示:

Figure 3. Frenet Frame

由上图可知,局部坐标系的T方向为曲线的切线方向。主法向N总是指向曲线凹侧。

4. Conclusion

曲线的活动标架是《微分几何》中一个很基础的概念。有了曲线的活动标架,扫掠造型Sweep算法的实现有了一些思路。当给定一个轮廓线后,将轮廓线沿着路径曲线扫掠可以理解为将轮廓线变换到曲线的活动标架中。

本文主要演示了Frenet活动标架的例子,读者可以将GeomFill_TrihedronLaw其他的子类表示的其他类型活动标架自己实现,加深理解。

5. References

1. 赵罡, 穆国旺, 王拉柱. 非均匀有理B样条. 清华大学出版社. 2010

2. 陈维桓. 微分几何. 北京大学出版社. 2006

3. 朱心雄. 自由曲线曲面造型技术. 科学出版社.  2000

OpenCASCADE Trihedron Law的更多相关文章

  1. OpenCascade Law Function

    OpenCascade Law Function eryar@163.com 1.Introduction 在OpenCASCADE的TKGeomAlgo Toolkit中提供了一个Law Packa ...

  2. OpenCascade Sweep Algorithm

    OpenCascade Sweep Algorithm eryar@163.com Abstract. Sweeps are the objects you obtain by sweeping a ...

  3. OpenCASCADE AIS Manipulator

    OpenCASCADE AIS Manipulator eryar@163.com Abstract. OpenCASCADE7.1.0 introduces new built-in interac ...

  4. Convert BSpline Curve to Arc Spline in OpenCASCADE

    Convert BSpline Curve to Arc Spline in OpenCASCADE eryar@163.com Abstract. The paper based on OpenCA ...

  5. OpenCASCADE Shape Location

    OpenCASCADE Shape Location eryar@163.com Abstract. The TopLoc package of OpenCASCADE gives resources ...

  6. OpenCASCADE BRep Projection

    OpenCASCADE BRep Projection eryar@163.com 一网友发邮件问我下图所示的效果如何在OpenCASCADE中实现,我的想法是先构造出螺旋线,再将螺旋线投影到面上. ...

  7. OpenCASCADE Expression Interpreter by Flex & Bison

    OpenCASCADE Expression Interpreter by Flex & Bison eryar@163.com Abstract. OpenCASCADE provide d ...

  8. OpenCASCADE Data Exchange - 3D PDF

    OpenCASCADE Data Exchange - 3D PDF eryar@163.com Abstract. Today most 3D engineering model data are ...

  9. OpenCASCADE Interpolations and Approximations

    OpenCASCADE Interpolations and Approximations eryar@163.com Abstract. In modeling, it is often requi ...

随机推荐

  1. win10怎么安装JDK8,配置JDK8的环境变量

    win10怎么安装JDK8,配置JDK8的环境变量 本文详细说明怎么在win10上安装JDK8,方便小伙伴们快速学会安装与配置JDK. 工具/原料 windows10 jdk-8u51-windows ...

  2. weblogic的使用

    1.怎么修改weblogic的端口 创建好域之后,去域的下面找到config.xml文件,在里面加上<listen-port>80</listen-port>即可,访问时不用加 ...

  3. NancyFX 第九章 Responses(响应对象)

    和内容协商最最为紧密的当属Nancy的Response对象. 在本书的第一张你应该就已经看到过Response对象,之前是使用它的AsFile 方法返回一个简单文件. using Nancy; nam ...

  4. 29.Django session

    session 1.概述 cookie和session的区别 Cookie是保存在用户浏览器端的键值对,Session是保存在服务器端的键值对:Cookie做用户验证的时,敏感信息不适合放在Cooki ...

  5. 分享python分析wave, pcm音频文件

    最近研究的,我用的是python3.3, 用matplotlib画图, 下面代码演示分析pcm文件,如果是wave文件,把wave的文件头去掉就是pcm文件了. 代码如下 # -*- coding:u ...

  6. Redis的持久化机制包括RBD和AOF两种,对于这两种持久化方式各有优势

    RDB机制的策略 RDB持久化是指在指定的时间间隔内将内存中的数据和操作通过快照的方式保存到redis bin目录下的一个默认名为 dump.rdb的文件,可以通过配置设置自动的快照持久化的方式,我们 ...

  7. python爬微信公众号前10篇历史文章(5)-JSON相关内容小结

    json - JSON encoder and decoder JSON: JavaScript object notation,是一种轻量级的数据交换格式.JSON 是 JS 对象的字符串表示法,它 ...

  8. Java内存区域之程序计数器--《深入理解Java虚拟机》学习笔记及个人理解(一)

    Java虚拟机程序计数器 在书上的P39页 程序计数器干嘛的? 有了它,字节码解释器才可以知道下一条要执行的字节码指令是哪个. 无论是取下一条指令还是分支.循环.跳转.中断.线程恢复,都需要这个程序计 ...

  9. C语言第十次博客作业--结构体

    一.PTA实验作业 题目1: 结构体数组按总分排序 1. 本题PTA提交列表 2. 设计思路 求出每名学生的总分 定义i,j循环变量 for i=0 to n for j=0 to 3 p[i].su ...

  10. 自己动手写泛型dao

    在经过一系列的问题得到解决之后,泛型dao终于写出来了.泛型dao相比于以前写的dao最大的好处就是,大大提高了代码的复用性,以往我们要对数据库中表中的数据进行操作的时候,每张表都需要写一个dao来操 ...