maya中给到坐标点数据都是数组,所以写了个数组距离函数
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//定义distanceBetween函数
double distanceBetween(float p1[], float p2[])
{
double d;
d = sqrt(pow(p1[0] - p2[0], 2) + pow(p1[1] - p2[1], 2) + pow(p1[2] - p2[2], 2));
return d;
}
//主程序
int main()
{
float p1[3] = { 1.0,1.0,1.0 };//坐标点
float p2[3] = { 0.0,0.0,0.0 };
printf("%lf", distanceBetween(p1, p2));
}