0

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?

Scott Milner
  • 4,473
  • 1
  • 22
  • 41
Mon
  • 71
  • 2
  • Not sure but according to this thread you may try cos**(-1) for inverse funtion of cos – Duarte Farrajota Ramos May 13 '17 at 00:11
  • Googling a bit finally turned up a free online plotter that can do implicit surfaces, and your equation gave me this: http://i.imgur.com/poiqcRq.png. Is that what you're expecting? You can find the plotter at http://matkcy.github.io/surface.html. –  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 01: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 01:31

1 Answers1

1

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

or:

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:

lemon
  • 60,295
  • 3
  • 66
  • 136
  • 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. http://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. – Mon May 15 '17 at 01:34
  • @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. –  May 18 '17 at 02:07
  • @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? http://matkcy.github.io/surface.html – Mon Sep 22 '17 at 16:52
  • @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. –  Sep 22 '17 at 17:53