点击查看详细介绍

UF_CURVE_ask_centroid() 函数的参数解释说明、函数详细用法,以及实例代码演示

misnn 7年前 641 0

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


函数结构:
UF_CURVE_ask_centroid
(
tag_t curve_id,
double centroid [ 3 ]
)

函数说明:
计算曲线或固体边缘的质心(重心)。

函数参数:
第1个参数为输入:
curve_id代表参数变量,tag_t 为输入参数类型,曲线或边缘的对象标识符

第2个参数为输入:
输入double 双精度类型的参数,参数的变量格式为centroid [ 3 ],曲线或边缘的重心

UF_CURVE_ask_centroid函数实例代码演示:
在下面的例子中的代码创建了一个半圆,并计算它的质心。
[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_csys.h>
#include <uf_curve.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
if (irc)
{
char messg[133];
printf("%s, line %d: %s\n", file, line, call);
(UF_get_fail_message(irc, messg)) ?
printf(" returned a %d\n", irc) :
printf(" returned error %d: %s\n", irc, messg);
}
return(irc);
}
static void do_ugopen_api(void)
{
tag_t wcs_tag;
UF_CURVE_arc_t arc_coords;
tag_t arc;
double centroid[3];
tag_t centroid_id;
UF_CSYS_ask_wcs( &wcs_tag );
UF_CSYS_ask_matrix_of_object( wcs_tag, &arc_coords.matrix_tag );
arc_coords.start_angle = 0.0;
arc_coords.end_angle = 180.0*DEGRA;
arc_coords.arc_center[0] = 0.0;
arc_coords.arc_center[1] = 0.0;
arc_coords.arc_center[2] = 0.0;
arc_coords.radius = 1.0;


if (!UF_CALL(UF_CURVE_create_arc( &arc_coords, &arc)))
{
if (!UF_CALL(UF_CURVE_ask_centroid( arc, centroid)))
{
UF_CALL(UF_CURVE_create_point(centroid, ¢roid_id));
}
}

}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}




[/quote]

0

最新回复 (0)
请登录后发表新帖