@Craige_Hales和@米圖爾沙赫,
我對貝塞爾曲線的了解和經驗有限。 我已經看到它們在繪圖(建築和景觀美化)設計和服裝設計中的實用性。 當然,數學基礎對我來說總是很有趣。我在網路上查了一下,發現@米圖爾沙赫求Excel的貝塞爾樣條,B樣條,演算法是比較常見的一種。 一個連結Excel平滑演算法問題包含 zip 檔案的連結: http://xlrotor.com/Smooth_curve_bezier_example_file.zip該 zip 包含一個 2002 .xls 貝塞爾曲線範例,其中嵌入了自動化例程,用於從 Excel 平滑曲線中抓取像素並在曲線上插入點。它並不“精確”,並且使用了從曲線上抓取 4 個像素的技術。 端點在第一個插值點和最後一個插值點中使用兩次。
在 Craige 發表有關 GraphBuilder Line 元素選項使其成為曲線的帖子後,我發現 JMP 中使用的樣條線必須使用不同的演算法,因為端點斜率與 Excel 的非常相似。我啟動了一個腳本,透過提取 GB 圖的像素來執行一些 DSP(數位訊號處理)。 然後我找到了上面列出的網絡鏈接,並決定僅使用 Excel 電子表格中的插值點並將其與 GB 線(曲線)覆蓋。 下面的第一個螢幕截圖描繪了 Excel 工作表,其中包含帶有貝塞爾樣條線和插值點的 Excel 圖形,這些點會作為旋轉 B 點添加到 JMP 表中。第二張圖顯示了疊加了 Excel 插值點的 JMP GB 線(曲線)。
Excel Interpolated Points > Spin B in JMP tableExcel Interpolated Points > Spin B in JMP tableExcel 插值點 > JMP 表中的旋轉 B
JMP Line(curve) spline overlaid with Excel interpolationsJMP Line(curve) spline overlaid with Excel interpolations與 Excel 插值疊加的 JMP 線(曲線)樣條曲線
您會注意到插值與上尾部的 JMP 線(曲線)略有偏移,這可能是由於插值演算法、Excel 和 JMP 曲線的差異或兩者的組合造成的。 請注意,這 4 個點略高於 Excel 圖表中的曲線。
因此,我的結論是 JMP GB 線(曲線)樣條線與 Excel 貝塞爾曲線非常相似。我的興趣不高,但如果我感到無聊,我可能會完成我的 DSP 腳本來「獲取」直線(曲線)點。早期版本的 JMP 用於報告已儲存的 .jrn 檔案中的曲線點,現在 .jrn 檔案中僅引用隱藏函數。
現在,如果我就這個問題進行諮詢,我的第一組問題將是:
- 這些數據(4分)從何而來,目標是什麼?
- 樣條曲線與直線和多項式一樣,可用於建立校準曲線(用於插值的曲線)來取代複雜的函數關係。 然而,出於準確性目的,如果要根據曲線計算插值,建議定期資料間隔和複製。 由於 X 值的間隔不規則,我想知道是否有第三個(或更多)變數同時影響 X 和 Y。 例如,兩者都是來自每日或每週測試讀數的讀數。
- 是否存在一個基本的首要原則,以 X 和 Y 的關係為基礎,例如:劑量反應;細胞生長;污染腐蝕等
- 為什麼積分這麼少? 複製的成本是多少?
根據我的經驗,如果存在基本的非線性關係,那麼通常值得付出努力來獲取數據並擬合關係以估計參數(學習曲線、退化曲線)等。正如在Craige Hales,控制點(數量和位置)、節點和端點的微小差異可能會導致樣條曲線的曲率(曲線上的點)產生很大差異,尤其是在「x」中存在較大間隙的情況下。我的預感是 Excel 故意不發布曲線樣條的點或公式,因此人們不會像擬合模型一樣使用它來進行估計。請注意,當 X 值和複製值「接近」時,插值的風險要小得多。
樣條線在起點和終點選擇的斜率對於 JMP 和 Excel 來說似乎不同。 樣條線在每對點之間使用不同的三次方,可以平滑地連接大量點,以匹配斜率和曲率。 如果只有四個點,則將三次擬合到這四個點並使用公式進行插值可能是有意義的。
也許我們會得到統計學家的答案。
Graph Builder can do it. So can Fit Y by X.Graph Builder can do it. So can Fit Y by X.圖形產生器可以做到這一點。 所以可以用 X 來擬合 Y。
對於這裡造成的混亂,我深感抱歉。
數據:

在JMP中,我用X擬合Y


如果我在Excel中輸入相同的數據

我明白了

請注意,在 JMP 綠線中,左下角周圍的曲線(X 值 2-3 之間)有一點振盪/扭結,而在 Excel 中並非如此。
我的最終目標是從該行插入值,因此如果 Excel 和 JMP 給出兩個不同的行,那麼我最終會得到不同的插值。
思考@gzmorgan0解釋,您可以在圖形產生器中執行此操作:
Select Points, then SHIFT to add the lineSelect Points, then SHIFT to add the line選擇“點”,然後按 SHIFT 鍵新增線
這就是我想做的
使用平滑曲線功能複製 Excel 的散佈圖。
如果我使用 JMP fit Y by X 和靈活的脊柱,我會得到與 Excel 使用散點圖 + 平滑線產生的曲線不同的曲線。 我相信Excel正在使用貝塞爾曲線擬合。
數據點:
旋轉| X |是
一個 | 2.41 | 2.41 846.8692
一個 | 0.93 | 0.93 77.043
一個 | 1.37 | 1.37 155.2193
一個 | 1.96 | 1.96 390.4639

我不想使用柔性樣條線來繪製這條線,但我想強制貝塞爾曲線。 我希望這是有道理的。
謝謝
嗨克雷格,
我試著去理解 path() 函數和移動點、控制點、貝塞爾點。
從我掌握的數據來看,我有以下四點
點=
[ 0.93 77.04 1,
1.37 155.22 0,
1.96 390.46 0,
2.41 846.87 3];
當我將其放入路徑函數中時,我在點 1 和點 4 之間得到一條線,但它沒有經過點 2 和點 3。 我錯過了什麼嗎?
謝謝。
多個答案,取決於您需要做什麼。 這裡有一些。
對於 2D 圖形,您可以使用路徑函數。 您無法透過搜尋 Bezier 找到它,因為腳本索引將其拼寫為 Bézier。 嘗試搜尋 zier。@XanGregg @sheila_loring
此範例使用可拖曳手把擴充了腳本索引範例。
// initial data; points 3 and 5 are not initially constrained about point 4
points = [
10 10 1,// move-to
30 70 0,// control point
40 10 0,// control point
50 40 3,// bezier
60 60 0,// control point
70 20 0,// control point
90 10 3 // bezier
];
// moving a square handle will call this function to
// copy the handle coordinates to the matrix
setpoint = Function( {index, x, y}, // parameters
{angle, distance}, // local variables
// copy to the matrix
points[index, 1] = x;
points[index, 2] = y;
// 3 and 5 are constrained about 4, comment out to see why...
// if the angles don't match, it isn't smooth
If( index == 3 | index == 5,
other = If( index == 3, 5, 3 ); // if I'm 3, he must be 5, etc
// trig in radians, 2*pi is 360
// atan does all 4 quadrants with 2 arguments
angle = ATan( points[index, 2] - points[4, 2], points[index, 1] - points[4, 1] );
// maintain other's distance
distance = Sqrt( (points[other, 2] - points[4, 2]) ^ 2 + (points[other, 1] - points[4, 1]) ^ 2 );
// fix other's angle to match my angle, but opposite me
points[other, 1] = points[4, 1] + distance * Cos( angle + Pi() );
points[other, 2] = points[4, 2] + distance * Sin( angle + Pi() );
);
// redraw
gb << inval;
);
New Window( "Example",
gb = Graph Box(
Fill Color( "blue" );
// there is no good shortcut for creating handles; the JSL holds the instances
Handle( points[1, 1], points[1, 2], setpoint( 1, x, y ) );
Handle( points[2, 1], points[2, 2], setpoint( 2, x, y ) );
Handle( points[3, 1], points[3, 2], setpoint( 3, x, y ) );
Handle( points[4, 1], points[4, 2], setpoint( 4, x, y ) );
Handle( points[5, 1], points[5, 2], setpoint( 5, x, y ) );
Handle( points[6, 1], points[6, 2], setpoint( 6, x, y ) );
Handle( points[7, 1], points[7, 2], setpoint( 7, x, y ) );
// construction lines
Pen Color( "red" );
Line( {points[1, 1], points[1, 2]}, {points[2, 1], points[2, 2]} );
Line( {points[3, 1], points[3, 2]}, {points[4, 1], points[4, 2]} );
Line( {points[4, 1], points[4, 2]}, {points[5, 1], points[5, 2]} );
Line( {points[6, 1], points[6, 2]}, {points[7, 1], points[7, 2]} );
// the bezier
Pen Color( "black" );
Path( points );
)
);我意識到我還應該限制移動點 4 來拖曳點 3 和 5。 (沒做過,應該很容易。)
Bezier control pointsBezier control points貝塞爾曲線控制點
也許您需要樣條線。 我不確定腳本索引中樣條曲線、p 樣條曲線、b 樣條曲線之間的差異是什麼。 我用了樣條線HeatColor、樣條線、內插法製作這條曲線
spline coef, spline evalspline coef, spline eval樣條係數、樣條評估
JMP 的 3D OpenGL 支援中也支援貝塞爾樣條線: https://www.jmp.com/support/help/14-2/bezier-curves.shtml這可能有助於繪製曲面。 一個糟糕的例子隱藏在快速傅立葉變換視頻
很棒的帖子@杜安·海耶斯了解三次樣條
我一路上遇到的一件事: https://www.tinaja.com/glib/bezconn.pdf