根据指定距离分割折线
来源:互联网 发布:淘宝企业店铺如何申请 编辑:程序博客网 时间:2024/06/05 02:56
/// <summary>
/// 根据指定距离分割折线
/// </summary>
/// <param name="coords">折线坐标,长度为2*n</param>
/// <param name="result">返回的分段节点坐标</param>
/// <param name="length">指定分割长度</param>
private void CalSplitPoints(double[] coords, ref double[] result, double length)
{
int size=coords.Length/2;
double[] lengths = new double[size];
double totalLength = 0;
int i;
lengths[0] = 0;
for (i = 1; i < size; i++)
{
int tempI = 2 * (i-1);
lengths[i] = Math.Sqrt((coords[tempI + 2] - coords[tempI]) * (coords[tempI + 2] - coords[tempI])
+ (coords[tempI + 3] - coords[tempI + 1]) * (coords[tempI + 3] - coords[tempI + 1]));
totalLength += lengths[i];
}
axis = new double[2 * (int)(totalLength / length) + 2];
int count = axis.Length / 2;
int currentI = -1;
double currentL = 0;
double tempLengths=0;
axis[0] = coords[0]; axis[1] = coords[1];
for (i = 1; i < count; i++)
{
currentL = (i-1) * length;
while ((currentL + length) > tempLengths)
{
if (currentI == size - 1)
{
break;
}
currentI++;
tempLengths += lengths[currentI];
}
double lastLength = tempLengths - lengths[currentI];
double nowLength = currentL + length - lastLength;
//nowLength为点currentI-1和currentI两点间离点currentI-1的距离
double ratio = nowLength / lengths[currentI];
int tempI = 2 * (currentI-1);
axis[2 * i] = ratio * (coords[tempI + 2] - coords[tempI]) + coords[tempI];
axis[2 * i+1] = ratio * (coords[tempI + 3] - coords[tempI+1]) + coords[tempI+1];
}
}
- 根据指定距离分割折线
- 根据指定要求分割字符串
- HDU 2050 折线分割平面(根据直线递推)
- VC字符串根据指定字符分割成CStringArray
- 2050 折线分割平面
- HDU2050折线分割平面
- 折线分割平面问题
- 折线分割平面
- HDOJ2050 折线分割平面
- hdu2050 折线分割平面
- 折线分割平面
- 折线分割平面
- 1023折线分割平面
- 折线分割平面
- 折线分割平面
- HDU2050 折线分割平面
- 折线分割平面 2050
- hdoj2050 折线分割平面
- 【模拟】【RQNOJ】统计数字
- 11122
- asp.net session 介绍一三种Session存储方式
- WPF/Silverlight中的数据绑定问题
- Table 隔行变色、悬停变色
- 根据指定距离分割折线
- 【转】批处理入门
- 北京短信二次接口开发
- learning words and word phrase in let's talk in english
- 利用MSXML解析XML文本(VC)
- IT 人士工作中的十不要!
- 运行命令集
- Beanutils的使用
- 得到屏幕坐标toScreenPoint