TLDR: I'm exploring with fractals in C4d. is there any other alternative to create mandelbrot sets, in cinema4d?
Hi i don't have Vectron, or Houdini. I tried to replicate this on python:
import c4d
from math import sqrt
import random
import numpy as np
#Welcome to the world of Python
def main():
maxiter = 5
#obj = doc.SearchObject("Cubo")
obj = op[c4d.ID_USERDATA,1] #create user data parameter with link option and drop the object that you want to use
#pointCount = obj.GetPointCount()
pts = obj.GetAllPoints()
ptCount = obj.GetPointCount()
for x in range(ptCount):
if(mandel(pts[x][0],pts[x][1],pts[x][2],maxiter)):
obj.SetPoint(x,c4d.Vector(0,0,0))
else:
obj.SetPoint(x,c4d.Vector(1,1,1))
#obj.SetPoint(x,c4d.Vector(random.randint(0,40),random.randint(0,40),random.randint(0,40)))
#obj[c4d.ID_BASEOBJECT_REL_POSITION]= c4d.Vector(0,0,random.randint(0,1))
def mandel( x0,y0,z0,imax):
x = x0
y = y0
z = z0
n =8
for i in range(imax):
xnew = x * x - y * y +x0
ynew = 2* x * y + y0
r = sqrt(x*x +y*y + z*z)
theta = np.arctan2(sqrt(x*x+y*y),z)
phi = np.arctan2(y,x)
xnew = pow(r,n)* np.sin(theta*n)* np.cos(phi *n)+x0
ynew = pow(r,n)* np.sin(theta*n)* np.cos(phi *n)+y0
znew = pow(r,n) * np.cos(theta*n) +z0
if(xnew * xnew + ynew * ynew +znew*znew> 8):
return(i)
x = xnew
y = ynew
z = znew
return(imax)
Using a cube polygon object as user data to my script. I used the mandelbrot formula to every point.
To install numpy, i located the Cinema4d python files on:
[C4Dfolder]\resource\modules\python\libs\win64\python27.vs2008.framework
pythons versions may vary, and followed this:
https://stackoverflow.com/questions/35700063/pip-install-python-2-7-windows-7
downloaded https://bootstrap.pypa.io/get-pip.py on python folder.
Save the file as getpip.py
Run it from cmd: python getpip.py install|
and python -m pip install numpy