2016-10-23 11 views
1

私はラケットと博士ラケットを使用しています。 plotと呼ばれる素晴らしいライブラリがあり、グラフを2Dまたは3Dでプロットすることができます。私はこの方程式をプロットしようとすると、しかしラケット付き3次元グラフをプロットする方法

(plot3d (surface3d (lambda (x y) (* x 3)) (- 10) 10 (- 10) 10)) 

enter image description here

パッケージインポートした後:

(require plot) 

を私はf(x,y) = 3 * xのようなグラフをプロットすることができ

f (x,y,z) = 2(x-2)^2 + (y-1)^2+(z-3)^2 - 10 

(plot3d (surface3d (lambda (x y z) (+ (* 2 (expt (- x 2) 2)) 
             (expt (- y 1) 2) 
             (expt (- z 3) 2) 
             -10)) 
             (- 10) 10 (- 10) 10)) 

私は理解できないエラーの大きなメッセージが表示されます:

surface3d: contract violation 
    expected: a procedure that accepts 2 non-keyword argument 
    given: #<procedure:...top/graficos.rkt:14:19> 
    in: the 1st argument of 
     (->* 
     ((-> any/c any/c Real)) 
     ((or/c Real #f) 
     (or/c Real #f) 
     (or/c Real #f) 
     (or/c Real #f) 
     #:alpha 
     Nonnegative-Real 
     #:color 
     (or/c 
     Integer 
     Symbol 
     String 
     (recursive-contract g147 #:impersonator) 
     (cons/c 
      Real 
      (cons/c Real (cons/c Real '())))) 
     #:label 
     (or/C#f String) 
     #:line-color 
     (or/c 
     Integer 
     Symbol 
     String 
     (recursive-contract g147 #:impersonator) 
     (cons/c 
      Real 
      (cons/c Real (cons/c Real '())))) 
     #:line-style 
     (or/c 
     Integer 
     'transparent 
     'solid 
     'dot 
     'long-dash 
     'short-dash 
     'dot-dash) 
     #:line-width 
     Nonnegative-Real 
     #:samples 
     Positive-Integer 
     #:style 
     (or/c 
     Integer 
     'transparent 
     'solid 
     'bdiagonal-hatch 
     'crossdiag-hatch 
     'fdiagonal-hatch 
     'cross-hatch 
     'horizontal-hatch 
     'vertical-hatch) 
     #:z-max 
     (or/c Real #f) 
     #:z-min 
     (or/c Real #f)) 
     any) 
    contract from: 
     <pkgs>/plot-lib/plot/private/plot3d/surface.rkt 
    blaming: /home/pedro/Desktop/graficos.rkt 
    (assuming the contract is correct) 
    at: <pkgs>/plot-lib/plot/private/plot3d/surface.rkt:49.9 

これをグラフ化するabsolutelly可能です。私はウルフラムアルファでそれをやった:

enter image description here

+0

[documentation of surface3d](https://docs.racket-lang.org/plot/renderer3d.html?q=plot#%28part._3.D_.Surface_.Renderers%29)を読むと、機能パラメータには3つではなく2つのパラメータがあることを確認してください。 – Renzo

+1

'f(x、y、z)= 2(x-2)^ 2 +(y-1)^ 2 +(z-3)^ 2 - 10'は方程式ではなく、a 3つのパラメータの関数。あなたが探している方程式は '2(x-2)^ 2 +(y-1)^ 2 +(z-3)^ 2 = 10'(つまり' f(x、y、z)= 0')、これはあなたがWolframに入力したものです。変数の1つを求めて解いてください。 – molbdnilo

答えて

2

かかわらず、ラケットの実装の詳細を、何をやろうとしていることは意味がありません。あなたはR^3からRに写像する関数をプロットしようとしています.3次元のサーフェスプロットとしてはできません:4が必要です。

これまでのところ、この問題は、あなたがしようとしていることを再考することです。 1つのアプローチは、あなたの関数をカレーして、その引数の固定値のためにプロットできるようにすることです:(plot3d (surface3d (curryr (lambda (x y z) ...) 3.0) ...))は、例えばz = 3.0に対してプロットします。

+0

実際、私はそれをWolfram Alphaで試してみました。私は私のポストを更新します。 –

+0

@fallowzito alphaが行ったことは、その関数がゼロの表面をプロットすることです。それは関数をプロットするのと同じことではありません。 – tfb

+0

あなたは絶対に正しいです。そして私はどうやってそれをするのですか?この表面をどのようにプロットするのですか? –

関連する問題