# Creating mesh on a surface with two variables

I have an equation like this: $\cos(z)+\sin(x)+\sin(y)=1$ and I want to do something like:

Graph in blender a function of two variables,

I followed the proposed method in the same post. It was great and worked fine for many cases.

1) I cannot use arccosine(1-sin(x)-sin(y)). arccos and acos don't work either. What is the solution? Thanks in advance for your comments.

2) is there any possible way to determine a range for $z$ as well?

• Not sure but according to this thread you may try cos**(-1) for inverse funtion of cos – Duarte Farrajota Ramos May 13 '17 at 0:11
• Googling a bit finally turned up a free online plotter that can do implicit surfaces, and your equation gave me this: i.imgur.com/poiqcRq.png. Is that what you're expecting? You can find the plotter at matkcy.github.io/surface.html. – user27640 May 14 '17 at 16:38
• Wow, perfect! Thanks. That is exactly what I want. Actually, this is another equation I like to have! How can I add more vertices (say se=pecifically N points) on the surface and save them in a .txt file? – Mon May 15 '17 at 1:31
• Is there any way to also calculate the normal vector to this surface at each of these points on the surface and save them in a separate file? – Mon May 15 '17 at 1:31

The Python function 'acos' has a parameter's domain between -1 and 1. If the parameter is out of this, you get a 'domain error'.

So for instance, you can set the following formula:

acos( (1-sin(x)-sin(y)) % (1 if (1-sin(x)-sin(y)) >0 else -1 ) )


or more simple (using 'fmod' which is C style modulo as Python's native modulo sign rely on the divisor sign)

acos( fmod( (1-sin(x)-sin(y)), 1 ) )


which is limiting the parameter's values.

Or alternatively to have a linear transition, limiting the parameter value like this:

acos( ((1-sin(x)-sin(y)) + 1) / 4 )


The result is the following:

or:

safe_list = ['math', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh',

• @Mohsen The sine function produces a value from -1 to 1 inclusive, and since x and y are independent of each other, sin(x)+sin(y) has a range of -2 to 2 inclusive. The problem occurs when this gets negative, 1-sin(x)-sin(y) will then be greater than 1, which is an invalid value for acos. 1-sin(x)-sin(y) is the same as 1-(sin(x)+sin(y)) and subtracting a negative value is equivalent to adding its absolute value. – user27640 May 18 '17 at 2:07