vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
547 stars 90 forks source link

Please let me know whether Asymptote can crop 3D surfaces #270

Open justonlyasy opened 2 years ago

justonlyasy commented 2 years ago
  1. In graph3.asy, the command zlimits doesn't need bool crop=NoCrop.

  2. A problem which relative to 1.

This example run on http://asymptote.ualberta.ca/

import graph3;
import contour;
import grid3;
import palette;

size(8cm);

currentprojection=orthographic(1,-1,0.7);
limits((-4,-2,0),(0,2,5));

real H(pair z){
  real x=z.x,y=z.y;
  real a=sqrt(((x^2-y^2+3*x+2)^2+(2*x*y+3*y)^2)+2.2204e-16);
  real b=sqrt(((x^3+5*x^2-3*x*y^2+8*x-5*y^2+6)^2+(3*x^2*y+10*x*y-y^3+8*y)^2)+2.2204e-16);
  return 3*(a/b);
}

surface s=surface(H,(-4,-2),(0,2),25);

draw(s,mean(palette(s.map(zpart),Rainbow())),black);

workspace (1)

I want to it looks like tZQRX

The command limits((-4,-2,0),(0,2,5)); doesn't work!

Update 30/12/2021 https://tex.stackexchange.com/questions/383343/complicated-surface-plot-projection-and-cut

charlesstaats commented 2 years ago

https://tex.stackexchange.com/a/159240/484

On Sun, Sep 19, 2021 at 1:01 AM asymptotenvt @.***> wrote:

1.

In graph3.asy, the command zlimits doesn't need bool crop=NoCrop. 2.

A problem which relative to 1.

This example run on http://asymptote.ualberta.ca/

import graph3; import contour; import grid3; import palette;

size(8cm);

currentprojection=orthographic(1,-1,0.7); limits((-4,-2,0),(0,2,5));

real H(pair z){ real x=z.x,y=z.y; real a=sqrt(((x^2-y^2+3x+2)^2+(2xy+3y)^2)+2.2204e-16); real b=sqrt(((x^3+5x^2-3xy^2+8x-5y^2+6)^2+(3x^2y+10xy-y^3+8y)^2)+2.2204e-16); return 3*(a/b); }

surface s=surface(H,(-4,-2),(0,2),25);

draw(s,mean(palette(s.map(zpart),Rainbow())),black);

[image: workspace (1)] https://user-images.githubusercontent.com/52594258/133919578-80f62e5f-ee1e-4851-9c7d-5890e4671b14.png

I want to it looks like [image: tZQRX] https://user-images.githubusercontent.com/52594258/133919681-04ad1299-2d98-4deb-a831-cafd7b7bf90b.jpg

The command limits((-4,-2,0),(0,2,5)); doesn't work!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vectorgraphics/asymptote/issues/270, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBQISY6MFAR66Q6L4JTX5LUCWKELANCNFSM5EKCCLSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

justonlyasy commented 2 years ago

@charlesstaats Thanks for your link and your answer. However, your answer can't get this, meshpen image I also know this issue need much time and mathematics.

zzdatura commented 2 years ago

One easy workaround for your problem @justonlyasy might be using a custom linear scale in z bounded by your upper limit:

import graph3;
import contour;
import grid3;
import palette;

size(8cm);

// add these three lines instead of the limits function later
scale(Linear, Linear,
      scaleT(new real(real x) {return min(5, x);},
             new real(real x) {return x;}));

currentprojection=orthographic(1,-1,0.7);

real H(pair z){
  real x=z.x,y=z.y;
  real a=sqrt(((x^2-y^2+3*x+2)^2+(2*x*y+3*y)^2)+2.2204e-16);
  real b=sqrt(((x^3+5*x^2-3*x*y^2+8*x-5*y^2+6)^2+(3*x^2*y+10*x*y-y^3+8*y)^2)+2.2204e-16);
  return 3*(a/b);
}

surface s=surface(H,(-4,-2),(0,2),25);

draw(s,mean(palette(s.map(zpart),Rainbow())),black);

This is the output, you might want to play with the mesh density:

test