Adept Scientific - English
The world's best software for research, science and engineering.
flag arrow
clearclear
 

 Adept Store | register Join My Adept | Flags  
Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055  
UKusdedksvnofi
Home
Products
Training
Consultancy
 Buy Online
Downloads
Education
Support
My Adept
International |  About Us |  Contact Us |  Press Room |  Jobs


The Next Steps

• Ask us a question
• Maple Product Tour
• Buy Maple Now
• View Maple Pricing
• Find out about Online Training
• Download a Brochure
• Request a Brochure
• Download a Demo
• Request a Demo
• Meet Our Team
• Read our RSS Feeds

Learn More

Maple Home
Maple 11 Professional
Maple 11 Academic
Maple 11 Student Use
Recorded Online Seminars
FREE Training Resources


MapleNet
Maple T.A.
MapleConnect
BlockImporter for Simulink
BlockBuilder for Simulink
Maple Toolboxes
Maple Rave Reviews
Maple Study Guides
Books about Maple
System Requirements

View Maple 10 in Action
Product Comparison Chart

Latest Information

New Features: Professional
New Features: Academic
The Maple Reporter
The Maple Reporter Online
Numerical Algorithms Group
(NAG)


Service & Support

Maple 10 Training Videos
MaplePrimes, blogs, forums
Elite Maintenance Program
Application Centre
Powertools
Maple User Group (MUG)
Join the Maple User Group
(MUG)

Search the Knowledge Base
Technical Support request

List Archives >  Maple User Group List Archive >  Archive by date >  This Month By Date >  This Month By Topic

[MUG] Re: Question about texturing using Maple

Search email archive for  

[MUG] Re: Question about texturing using Maple
Author: Maple User Group    Posted: Wed, 22 May 2002 16:37:40 -0400

>> From: Maple User Group "maple_gr"

| >> From: "bguerrieri"
| > plot3d({cos(x)*sin(y), 0},x=-Pi..Pi,y=-Pi..Pi,color=cos(x*y);
|
| which shows a section of the x-y plane as well as its "transform"
| under f:=(x,y)->cos(x)*cos(y), both shaded according to the law g :=
| (x,y)->x*y;
|
| I seem to run into difficulty when I attempt to "design" my own
| coloring function, admittedly an "ugly" one such as
| g := proc(x,y)
| local a;
| if (x>=-evalf(Pi) and x<0) then a := 1: fi:
| if (x>=0 and x<=evalf(Pi)) then a := 2: fi:
| RETURN(a);
| end:
|
| The call
| plot3d(0,u=-Pi..Pi,v=-Pi..Pi,color=g(u,v)); generates the following:
| Error, (in g) cannot evaluate boolean: ...

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Fri, 17 May 2002 17:24:27 -0300 (BRT)
From: Humberto Jose Bortolossi "hjbortol"
To: MUG "maple-list"
Subject: Question about texturing using Maple

Hi!

Try the following:

g := proc(x,y)
local a;
if not(type(x, numeric)) or not(type(y, numeric)) then
RETURN('g'(x, y));
fi:
if (x>=-evalf(Pi) and x<0) then a := 1: fi:
if (x>=0 and x<=evalf(Pi)) then a := 2: fi:
RETURN(a/2);
end:

You have to include the ``if not(type(x, numeric)) ...'' to avoid the
evaluation of g(x, y) with the symbolic x since Maple tries to evaluate
g(x, y) before x and y assume some numeric value.

Best regards, Humberto.
"hjbortol"

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Sat, 18 May 2002 23:22:37 -0700 (PDT)
From: Robert Israel "israel"
To: MUG "maple-list"
Subject: Question about texturing using Maple

Premature evaluation strikes again! The main problem is that
your g(u,v) can't be evaluated when u and v are symbolic variables.
Try this:

g:= proc(x,y)
proc(x,y)
local a;
if not type([x,y],list(numeric)) then 'procname(x,y)'
elif (x >= -evalf(Pi) and x < 0) then 1/2
else 1
fi;
end;

Note that the colour function is interpreted as a "hue", which should
be in the interval 0 to 1; both 0 and 1 are red.

Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: Stanley J Houghton "S.J.Houghton"
Date: Mon, 20 May 2002 15:19:08 +0100
To: "bguerrieri" "maple-list"
Subject: Question about texturing using Maple

It is another case of premature evaluation. I solved it by quoting the
color specifier. However, I had to use two pairs of quotes as in

color=''g(u,v)''

An alternative is to ensure that your proc is "self-quoting" when its
paramteres are symbolic (i.e. not constant values) as follows:

> g := proc(x,y)
> local a;
> if not(type(x,constant)and type(y,constant)) then
> RETURN('procname'(u,v))
> fi;
> if (x>=-evalf(Pi) and x<0) then a := .5: fi:
> if (x>=0 and x<=evalf(Pi)) then a := 1: fi:
> RETURN(a);
> end:

Hope it helps

Stan


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Tue, 21 May 2002 11:28:19 +0200
From: Preben Alsholm "ifakpa"
To: "maple-list" "bguerrieri"
Subject: Question about texturing using Maple

If you make your procedure g return unevaluated when it receives a
non-numeric input then everything is OK. E,g. like this:

g := proc(x,y)
> local a;
> if not type(x,numeric) then return 'procname(x,y)' fi;
> if (x>=-evalf(Pi) and x<0) then a := 1: fi:
> if (x>=0 and x<=evalf(Pi)) then a := 1/2: fi:
> a;
> end:

--
Preben Alsholm
Institut for matematik (Department of Mathematics)
DTU (Technical University of Denmark)



-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: Alec Mihailovs "amihailo"
To: "maple-list"
Subject: Question about texturing using Maple
Date: Tue, 21 May 2002 20:40:08 -0400

For this particular example, both a:=1 and a:=2
would give the same red color, because the HUE color
depends only on the fractional value. Let's change it to
something different, say

> g:= (x,y)->Heaviside(x)/2;

or

> g := (x,y)->`if`(x>=0,.5,0);

or

> g := proc(x,y) if x<0 then 0 else .5 fi end:

or the example of g in your letter. Then

> plot3d((u,v)->0,-Pi..Pi,-Pi..Pi,color=g);

will produce the plot.

Best wishes,
Alec Mihailovs
http://webpages.shepherd.edu/amihailo/

[View Complete Thread]



Previous by date: [MUG] Re: Numerical solution of ODE, Maple User Group
Next by date: [MUG] Handling "Too many levels of recursion" ?, Vladimir Bondarenko
Previous thread: [MUG] evaluating _F1 /_F2 in pdsolve o/p,  Nagaraj Mahavir
Next thread: [MUG] Handling "Too many levels of recursion" ?, Vladimir Bondarenko



Ready to buy?

Maple - single user licence
Add to shopping basket
$ 1,895.00
Upgrade to Maple 12 from v11
Add to shopping basket
$ 995.00
Upgrade to Maple 12 from v10 & below
Add to shopping basket
$ 1,395.00

Featured Downloads

Maple White Paper: Technical Knowledge - An Asset You Can Afford to Lose?
Maple in Electronics Application Pack
Maple in Robotics & Aerospace Application Pack
Maple in Finance Application Pack

Product Reviews

"Without the Maple software, we would have to spend weeks generating the equations of motion for every experiment. Then the chances that we did it right would basically be near zero. There would always be a mistake somewhere. It is very difficult to set up a dynamic motion model by hand."
- Jean-Claude PiedBeouf, Ph.D Manager of Robotics, Canadian Space Agency

"Its very good - highly accurate and easy to use. The speed of Maple allows me to change equations and quickly reintegrate them into the application, so more possibilities can be explored to achieve the precise effect desired."
Shawn Neely, Senior R & D Director for PDI/Dreamworks
adept

Top of the Page

Our Privacy and Terms and Conditions Statement
All Trademarks Recognised. Copyright © 2007, Adept Scientific plc.
Site designed and maintained by Adeptise

Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055