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?

  • $\begingroup$ Not sure but according to this thread you may try cos**(-1) for inverse funtion of cos $\endgroup$ – Duarte Farrajota Ramos May 13 '17 at 0:11
  • $\begingroup$ 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. $\endgroup$ – user27640 May 14 '17 at 16:38
  • $\begingroup$ 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? $\endgroup$ – Mon May 15 '17 at 1:31
  • $\begingroup$ 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? $\endgroup$ – 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:

enter image description here


enter image description here

For your information, the math functions available in the addon:

safe_list = ['math', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh',
    'degrees', 'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot',
    'ldexp', 'log', 'log10', 'modf', 'pi', 'pow', 'radians',
    'sin', 'sinh', 'sqrt', 'tan', 'tanh']

And these links to stack overflow:

| improve this answer | |
  • $\begingroup$ Thanks lemon for your reply. I understand the domain for acos, but I do not understand why It does not work. Can you please check this link. matkcy.github.io/surface.html sent by brasshat. Please read my last two comments above. This is what I want. Thanks in advance for your reply. $\endgroup$ – Mon May 15 '17 at 1:34
  • $\begingroup$ @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. $\endgroup$ – user27640 May 18 '17 at 2:07
  • $\begingroup$ @Duane, thanks. Got it. The arccosine domain is [0, pi]. So, it cannot be negative while 1-sin(x)-sin(y) can be negative sometimes. So, any idea for how can I make such a graph? matkcy.github.io/surface.html $\endgroup$ – Mon Sep 22 '17 at 16:52
  • $\begingroup$ @Mohsen You got the idea right, but the numbers wrong. The domain of arccos is [-1, 1] and 1-sin(x)-sin(y) has values in the range [-1, 3]. As for a solution, I have none, but I did post a workaround as an answer to creating mesh on an isosurface, and there's also an answer by Mutant Bob to that question, suggesting the marching cubes algorithm. $\endgroup$ – user27640 Sep 22 '17 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.