有時候我們并不知道一個函數可能會有什麼行為,例如XYZ.AngleTo的傳回值是0-2π還是0-π,又找不到對應的文檔,那就幹脆自己動手測試一下了,代碼如下:
Line line1 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(10, 0, 0));
Line line2 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 10, 0)); // L
Line line3 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(-10, 10, 0)); // \-
Line line4 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(-10, -10, 0)); // /-
Line line5 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(-10, 0, 0)); // --
Line line6 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 10, 0)); // |-
Line line7 = Line.CreateBound(new XYZ(0, 10, 0), new XYZ(10, 10, 0)); // =
double angle;
angle = line1.Direction.AngleTo(line2.Direction);
Trace.WriteLine(angle);
angle = line1.Direction.AngleTo(line3.Direction);
Trace.WriteLine(angle);
angle = line1.Direction.AngleTo(line4.Direction);
Trace.WriteLine(angle);
angle = line1.Direction.AngleTo(line5.Direction);
Trace.WriteLine(angle);
angle = line1.Direction.AngleTo(line6.Direction);
Trace.WriteLine(angle);
angle = line1.Direction.AngleTo(line7.Direction);
Trace.WriteLine(angle);
輸出值是:
1.5707963267949
2.35619449019234
2.35619449019234
3.14159265358979
1.5707963267949
用圖形表示就是這樣
