Month: June 2011
简单记在这里。 /Developer/Applications/FileMerge.app/Contents/MacOS/FileMerge -left “File1” -right “File2” -ancestor “File3” -merge “File4” 这个工具很好用,难免有需要整到脚本里用的时候。 -left -right -ancestor -merge 四个选项 参考:http://hints.macworld.com/article.php?story=2001102615104319
接上一篇Blog,这里用贝塞尔曲线来平滑多个点。 和样条插值不同,在多个点上作贝塞尔曲线的时候,曲线只穿过首尾两个点,中间的点都是作为控制点。 移动控制点,曲线也随之形变,可以造成一种拉扯的效果。在各种作图工具中,经常使用贝塞尔曲线来画曲线。一般的操作都是先画一条线段,然后可以通过拖动一个控制点来调整线段的弯曲程度。 作多点贝塞尔曲线只需要一个公式。所有的点的X值,被归一化到[0,1]区间内。 具体理论,可以参考这个页面Bézier curves。89年创建的,可有年头了。 这里还是贴代码吧。 首先需要得到X区间的总长度。 CGPoint startPt = [[_points objectAtIndex:0] CGPointValue]; CGPoint endPt = [[_points objectAtIndex:(self.pointCount - 1)] CGPointValue]; float amount = endPt.x - startPt.x; 然后就是曲线方程了,这个比样条插值要简单不少。 rank是指总的阶数,也就是实际的点数。这个函数表示n个点的贝塞尔曲线在x处的值。 这里的ux属于区间[0,1] float (^bezierSpline)(int rank, float ux) = ^(int rank, float ux) { float p = 0.0f; for (int i = 0; i < rank; i++)
曲线拟合是一个“数值计算“中的一个基本内容。在实际的项目中,使用拟合的目的就是从有限个点得到一条平滑曲线。曲线本身也是由点构成的,所以如何从有限个点得到曲线上的其它点,就是插值所关注的内容。
OmniGridView Code (GitHub) OmniGridView This is a half-finished grid view for iOS. Cause Apple’s UITableView only allows us to add and reuse vertical cells, we need to write our own scroll view when we want to have horizontal cells. HOW TO USE Drag the OmniGridView Folder to your project. Use the OmniGridView like any other
Posts navigation