[Scilab-users] Plot Heart Curve in Scilab

classic Classic list List threaded Threaded
6 messages Options
Hermes Hermes
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Plot Heart Curve in Scilab

Hello,
I've been looking at the forum, how to graph the following function:

x2=[-2:0.01:2];x1=[-1:0.01:1];
function val = Heart(x1, x2)
    val=(1.2*x2-sqrt(abs(x1)))^2+x1^2-1;
endfunction

And I have not found anything to guide me. Please, could you help me?

<http://mailinglists.scilab.org/file/t497622/Heartcurve.jpg>

Gracias



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Plot Heart Curve in Scilab

Hi Hermes,

 

One simple way is to display the 0-contour level of your “heart” function:

 

// START OF CODE
nx = 300;
ny = 200;
X0 = linspace(-1.2,1.2,nx);
Y0 = linspace(-1.5,2,ny);
X= X0.*.ones(ny,1);
Y= (Y0.*.ones(nx,1))';
Z = (1.2*Y - sqrt(abs(X))).^2 + X.^2 - 1;  // Heart function
clf()
a=gca();
a.x_label.text=" X";
a.y_label.text=" Y";
contour(X0,Y0,Z',[0  0]);
a.view = "2d";
// END OF CODE

 

Exercise:  fill it in red…

 

Regards,

Rafael

 

-----Original Message-----
From: users [mailto:[hidden email]] On Behalf Of Hermes
Sent: Tuesday, September 26, 2017 9:48 AM
To: [hidden email]
Subject: [Scilab-users] Plot Heart Curve in Scilab

 

Hello,

I've been looking at the forum, how to graph the following function:

 

x2=[-2:0.01:2];x1=[-1:0.01:1];

function val = Heart(x1, x2)

    val=(1.2*x2-sqrt(abs(x1)))^2+x1^2-1;

endfunction

 

And I have not found anything to guide me. Please, could you help me?

 

<http://mailinglists.scilab.org/file/t497622/Heartcurve.jpg>

 

Gracias

 

 

 

--

Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html

_______________________________________________

users mailing list

[hidden email]

http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Hermes Hermes
Reply | Threaded
Open this post in threaded view
|

Re: Plot Heart Curve in Scilab

Hi Rafa,
Here I present the task solved:
//start of code
nx=300;
ny=200;
X0=linspace(-1.2,1.2,nx);
Y0=linspace(-1.5,2,ny);
X=X0.*.ones(ny,1);
Y=(Y0.*.ones(nx,1))';
Z=(1.25*Y-sqrt(abs(X))).^2+X.^2-1;
clf()
a=gca();
a.x_label.text="X";
a.y_label.text="Y";
contour(X0,Y0,Z',[0,0]);
*Polyline=a.children.children(1)
Polyline.fill_mode="on";
Polyline.foreground=5;
Polyline.background=5;
Polyline.thickness=2;*
a.view="2d";
//end code

Two questions:
in the Helps of Scilab, where can I find the hierarchy trees for the graphic
objects?
How do I copy from SciNote to the Forum scripts and maintain the format of
it?
Thank you
Hermes



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Plot Heart Curve in Scilab

Hermes

For the second question, use email program with html format.

Regards
Rafael


From: users <[hidden email]> on behalf of Hermes <[hidden email]>
Sent: Wednesday, September 27, 2017 10:28:55 PM
To: [hidden email]
Subject: Re: [Scilab-users] Plot Heart Curve in Scilab
 
Hi Rafa,
Here I present the task solved:
//start of code
nx=300;
ny=200;
X0=linspace(-1.2,1.2,nx);
Y0=linspace(-1.5,2,ny);
X=X0.*.ones(ny,1);
Y=(Y0.*.ones(nx,1))';
Z=(1.25*Y-sqrt(abs(X))).^2+X.^2-1;
clf()
a=gca();
a.x_label.text="X";
a.y_label.text="Y";
contour(X0,Y0,Z',[0,0]);
*Polyline=a.children.children(1)
Polyline.fill_mode="on";
Polyline.foreground=5;
Polyline.background=5;
Polyline.thickness=2;*
a.view="2d";
//end code

Two questions:
in the Helps of Scilab, where can I find the hierarchy trees for the graphic
objects?
How do I copy from SciNote to the Forum scripts and maintain the format of
it?
Thank you
Hermes



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Denis Crété Denis Crété
Reply | Threaded
Open this post in threaded view
|

Re: Plot Heart Curve in Scilab

In reply to this post by Hermes
Hello,
It is also possible to use the couple of solutions (auricle, ventricle) of Z=0:
// Start of code
nx=201;
x=linspace(0,1,nx)'; // computation is done only for x=0 (it saves time for urgent needs!-)
auricle=(sqrt(x)+sqrt(1-x.^2))/1.2;
ventricle=(sqrt(x)-sqrt(1-x.^2))/1.2;
X0=[x;x($:-1:1);-x;-x($:-1:1)];
Y0=[auricle;ventricle($:-1:1);ventricle;auricle($:-1:1)];
scf();
// plot of a symmetrical polygone
xset("color",5);
xfpoly(X0,Y0);
// End of code

Thank you, I learned about "xfpoly" !
Denis

-----Message d'origine-----
De : users [mailto:[hidden email]] De la part de Hermes
Envoyé : mercredi 27 septembre 2017 22:29
À : [hidden email]
Objet : Re: [Scilab-users] Plot Heart Curve in Scilab

Hi Rafa,
Here I present the task solved:
//start of code
nx=300;
ny=200;
X0=linspace(-1.2,1.2,nx);
Y0=linspace(-1.5,2,ny);
X=X0.*.ones(ny,1);
Y=(Y0.*.ones(nx,1))';
Z=(1.25*Y-sqrt(abs(X))).^2+X.^2-1;
clf()
a=gca();
a.x_label.text="X";
a.y_label.text="Y";
contour(X0,Y0,Z',[0,0]);
*Polyline=a.children.children(1)
Polyline.fill_mode="on";
Polyline.foreground=5;
Polyline.background=5;
Polyline.thickness=2;*
a.view="2d";
//end code

Two questions:
in the Helps of Scilab, where can I find the hierarchy trees for the graphic objects?
How do I copy from SciNote to the Forum scripts and maintain the format of it?
Thank you
Hermes



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Denis Crété
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: Plot Heart Curve in Scilab

Hello,

Because of the sum of squares form there is also an easy parametric
description of this curve :

t=linspace(0,2*%pi,1000);
x=cos(t);
y=(sin(t)+sqrt(abs(x)))/1.25;
plot(x,y)

S.

Le 28/09/2017 à 11:38, CRETE Denis a écrit :

> Hello,
> It is also possible to use the couple of solutions (auricle, ventricle) of Z=0:
> // Start of code
> nx=201;
> x=linspace(0,1,nx)'; // computation is done only for x=0 (it saves time for urgent needs!-)
> auricle=(sqrt(x)+sqrt(1-x.^2))/1.2;
> ventricle=(sqrt(x)-sqrt(1-x.^2))/1.2;
> X0=[x;x($:-1:1);-x;-x($:-1:1)];
> Y0=[auricle;ventricle($:-1:1);ventricle;auricle($:-1:1)];
> scf();
> // plot of a symmetrical polygone
> xset("color",5);
> xfpoly(X0,Y0);
> // End of code
>
> Thank you, I learned about "xfpoly" !
> Denis
>
> -----Message d'origine-----
> De : users [mailto:[hidden email]] De la part de Hermes
> Envoyé : mercredi 27 septembre 2017 22:29
> À : [hidden email]
> Objet : Re: [Scilab-users] Plot Heart Curve in Scilab
>
> Hi Rafa,
> Here I present the task solved:
> //start of code
> nx=300;
> ny=200;
> X0=linspace(-1.2,1.2,nx);
> Y0=linspace(-1.5,2,ny);
> X=X0.*.ones(ny,1);
> Y=(Y0.*.ones(nx,1))';
> Z=(1.25*Y-sqrt(abs(X))).^2+X.^2-1;
> clf()
> a=gca();
> a.x_label.text="X";
> a.y_label.text="Y";
> contour(X0,Y0,Z',[0,0]);
> *Polyline=a.children.children(1)
> Polyline.fill_mode="on";
> Polyline.foreground=5;
> Polyline.background=5;
> Polyline.thickness=2;*
> a.view="2d";
> //end code
>
> Two questions:
> in the Helps of Scilab, where can I find the hierarchy trees for the graphic objects?
> How do I copy from SciNote to the Forum scripts and maintain the format of it?
> Thank you
> Hermes
>
>
>
> --
> Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users


--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users