采用Cardinal法构造插枝分段三次样条曲线 : 代码篇

说明:Spline类就是Cardinal样条曲线了,这个类里面记录了4个控制点:m_startControlPoint, m_startPoint, m_endPoint, m_endControlPoint, 分别按顺序对应Pk-1, Pk, Pk+1, Pk+2, 由于Cardinal是用多个线段去模拟曲线,所以我们在这里取20个点,这样,在Pk 和 Pk+1之间,有20个样本点,用画直线的方法将这些点按顺序连起来,连成的曲线段就是我们所要的Cardinal 曲线了

 

版权声明:

 

本文由timewolf完成,首发于CSDN ,作者保留版权。
未经许可,不得使用于任何商业用途。
欢迎转载,但请保持文章及版权声明完整。
如需联络请发邮件:karla9(AT)eyou(dot)com

 

using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace CardinalTest
{
 /// <summary>
 /// the declaration of the Spline, each spline contains 4 control points
 /// </summary>
 public class Spline
 {
  // it's the "Pk-1" point
  private Point3D m_startControlPoint;
  // it's the "Pk" point
  private Point3D m_startPoint;
  // it's the "Pk+1" point
  private Point3D m_endPoint;
  // it's the "Pk+2" point
  private Point3D m_endControlPoint;
  // that means we'll generate 20 sample points between Pk & Pk+1, so "u" will start from 0.00F
  // and the increase step is 0.05F
  private static readonly int m_sampleCount = 20;
  // the "t" in Cardinal altorithm
  private static readonly float m_tension = 0.0F;
  // store the result sample points
  private Point3D[] m_ctrlPoints;
  // indicate whether this spline is the first, if it is,
  //the m_startControlPoint & m_startPoint will be the same
  // because the 4 points can just determine the spline between Pk &

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值