//创建旋转体
int obj_count;
UF_FEATURE_SIGN mode_sign = UF_NULLSIGN;
tag_t generators[4], line1, line2, line3, line4;
char *body_limit[2] = {"0.0", "360.0"};
char *offsets[2]= {"0.0", "0.0" };
double origin[3] = {-2.0, 0.0, 0.0};
double direction[3] = {0.0, 1.0, 0.0};
UF_MODL_SWEEP_TRIM_object_p_t trim_data = NULL;
UF_CURVE_line_t sline1, sline2, sline3, sline4;
/* line#1 */
sline1.start_point[0] = 0.0;
sline1.start_point[1] = 0.0;
sline1.start_point[2] = 0.0;
sline1.end_point[0] = 0.0;
sline1.end_point[1] = 1.0;
sline1.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline1,&line1));
/* line#2 */
sline2.start_point[0] = 0.0;
sline2.start_point[1] = 1.0;
sline2.start_point[2] = 0.0;
sline2.end_point[0] = 2.5;
sline2.end_point[1] = 3.5;
sline2.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline2,&line2));
/* line#3 */
sline3.start_point[0] = 2.5;
sline3.start_point[1] = 3.5;
sline3.start_point[2] = 0.0;
sline3.end_point[0] = 1.0;
sline3.end_point[1] = 0.0;
sline3.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline3,&line3));
/* line#4 */
sline4.start_point[0] = 1.0;
sline4.start_point[1] = 0.0;
sline4.start_point[2] = 0.0;
sline4.end_point[0] = 0.0;
sline4.end_point[1] = 0.0;
sline4.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline4,&line4));
generators[0] = line1;
generators[1] = line2;
generators[2] = line3;
generators[3] = line4;
tag_t *object0;
UF_CALL(UF_MODL_create_revolution(generators, 4, trim_data,
body_limit, offsets, origin, false,
true, origin, direction, mode_sign,
&object0, &obj_count ));
设置密度:
int type = 1;
int unit = 3;
int accuracy = 1;
int count = 0;
int i;
double acc_val[11] = {.01,0,0,0,0,0,0,0,0,0,0};
double density = 0.5;
double massprop[47];
double massprop_stat[13];
UF_MODL_density_units_t units = UF_MODL_grams_centimeters;
double density0 = 6.80;
UF_MODL_set_body_density
(
*object0, units, density0
);
UF_CALL(UF_MODL_ask_mass_props_3d(object0,
count,
type,
unit,
density,
accuracy,
acc_val,
massprop,
massprop_stat));
for (i=0; i<47; i++)
{
char message[130];
sprintf(message,"[%d] = %f\n",i,massprop[i]);
UF_UI_write_listing_window(message);
}
UF_free(object0);
我创建一个旋转体,先设置了body密度,然后用UF_MODL_ask_mass_props_3d()函数求质量、质心和转动惯量,结果输出的是 47个相等的 负值。
高手请帮忙看看是哪里的错误。 |