2015-10-10 40 views
2

所以我使用一個開源.NET庫,用於繪製:FPlot視覺藝術品繪製2D功能等高線圖(使用FPlot)時

下面是我想要繪製函數: F(X,Y) = X^2 + 3 * Y^2 + 2 * X * Y

這裏就是我想要它看起來像:

enter image description here

澄清:

  1. 我不需要完全相同的appearence爲圖像中,我只需要情節是數學上正確
  2. 有10只在圖片conours,我需要儘可能多的能夠適合屏幕

以下是我試圖做到這一點:

 var graphFunction = new Function2D(); 
     graphFunction.source = "return (pow(x,2)+3*pow(y,2)+2*x*y)/10;"; 
     /* I'm dividing by 10 because otherwise the whole plot is solid color */ 
     graphFunction.Compile(true); 

這就是FPlot產生的情節如何查找密切:

enter image description here

這正是我想要的,但是當我縮小這裏發生了什麼: enter image description here Theese 額外的橢圓不應該在那裏,其實它們不存在,這僅僅是一個圖形化的假象,因爲當你放大到theese「假」省略號之一,這是你所看到的:

enter image description here

的問題可以在這一行:

 graphFunction.source = "return (pow(x,2)+3*pow(y,2)+2*x*y)/10;"; 

...或在FPlot源代碼中。有任何想法嗎?

UPDATE: 所以,圖中的z值似乎是問題所在。當圖中函數z = f(x,y)的值超過z1(max z)值時,它將重置爲z = z%z1(當z低於z0時會發生同樣的情況),這會導致這些「行」 - 他們不是像我想的那樣排隊。

這意味着解決方案是:在屏幕上將z0設置爲min f(x,y),並將z1設置爲max f(x,y)。

+0

有沒有辦法打開反鋸齒?或者畫一個尺寸爲4倍的畫布,然後縮小尺寸? – LutzL

+0

我試圖搞亂圖的所有屬性。沒有一個可以幫助 –

+0

這可能是實際線條和顯示像素之間的轉換,像Minecraft這樣的遊戲在從遠距離顯示重複紋理時也有類似的問題 – Cjen1

回答

1

使您FPlotLibrary.GraphControl在所有3個維度的值相同的顯示邊框和問題解決了:

 graphControl1.x0 = -40; 
     graphControl1.x1 = 40; 
     graphControl1.y0 = -40; 
     graphControl1.y1 = 40; 
     graphControl1.z0 = -40; 
     graphControl1.z1 = 40; 

enter image description here

順便說一句,「問題」再現,舉例來說,如果你做

 graphControl1.x0 = -40; 
     graphControl1.x1 = 40; 
     graphControl1.y0 = -40; 
     graphControl1.y1 = 40; 
     graphControl1.z0 = -1; 
     graphControl1.z1 = 1; 

enter image description here

+0

就是這樣,我完全忘記了z尺度。謝謝 –