五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

ChatGPT 于blender代碼建模的運用

2023-02-14 20:22 作者:DXH01  | 我要投稿

?

命令建模樹
較為粗糙
命令建立二維曼德爾分形
非常不錯

僅能建立簡單二維分形,復(fù)雜的三維分形代碼無法執(zhí)行,原因不明

代碼:

Mandlebrot分形

import bpy

import math

?

# Set the parameters for the Mandelbrot set

zoom = 300

x_offset = -0.5

y_offset = 0

max_iterations = 100

?

# Create a new mesh

mesh = bpy.data.meshes.new(name="Mandelbrot")

?

# Create an empty list to hold the vertices

verts = []

?

# Iterate over each pixel in the image and calculate the corresponding point in the Mandelbrot set

for y in range(0, bpy.context.scene.render.resolution_y):

??? for x in range(0, bpy.context.scene.render.resolution_x):

?????? ?# Calculate the complex number corresponding to the current pixel

??????? real = (x - 0.5 * bpy.context.scene.render.resolution_x) / zoom + x_offset

??????? imag = (y - 0.5 * bpy.context.scene.render.resolution_y) / zoom + y_offset

??????? c = complex(real, imag)

?

??????? # Initialize z to 0 and iterate the Mandelbrot function until the magnitude of z exceeds 2 or the maximum number of iterations is reached

??????? z = 0

??????? for i in range(max_iterations):

??????????? z = z*z + c

??????????? if abs(z) > 2:

??????????????? break

?

??????? # If the maximum number of iterations was reached, add the corresponding point to the vertex list

??????? if i == max_iterations - 1:

??????????? verts.append((real, imag, 0))

?

# Create a new object and link it to the scene

obj = bpy.data.objects.new(name="Mandelbrot", object_data=mesh)

bpy.context.scene.collection.objects.link(obj)

?

# Add the vertices to the mesh and update it

mesh.from_pydata(verts, [], [])

mesh.update()

?

巴恩斯利蕨:

import bpy

import random

?

# Set the initial point

x, y = 0, 0

?

# Define the transformation matrices

a = 0

b = 0

c = 0

d = 0

e = 0

f = 0

?

transformations = [

??? (0, 0, 0, 0.16, 0, 0),

??? (0.85, 0.04, -0.04, 0.85, 0, 1.6),

??? (0.2, -0.26, 0.23, 0.22, 0, 1.6),

??? (-0.15, 0.28, 0.26, 0.24, 0, 0.44),

]

?

# Set the number of iterations and scale factor

num_iterations = 100000

scale_factor = 100

?

# Create a list to store the vertices

vertices = []

?

# Perform the iterations

for i in range(num_iterations):

??? # Choose a random transformation

??? transformation = random.choice(transformations)

??? # Apply the transformation

??? a, b, c, d, e, f = transformation

??? x_new = a * x + b * y + e

??? y_new = c * x + d * y + f

??? x, y = x_new, y_new

??? # Add the point to the vertex list

??? vertices.append((x * scale_factor, y * scale_factor, 0))

?

# Create a new mesh

mesh = bpy.data.meshes.new(name="Barnsley Fern")

?

# Add the vertices to the mesh

mesh.from_pydata(vertices, [], [])

?

# Create a new object and link it to the scene

obj = bpy.data.objects.new(name="Barnsley Fern", object_data=mesh)

bpy.context.scene.collection.objects.link(obj)

?

?


ChatGPT 于blender代碼建模的運用的評論 (共 條)

分享到微博請遵守國家法律
八宿县| 宜丰县| 乐都县| 潼关县| 枣强县| 石阡县| 宜川县| 香格里拉县| 蒲城县| 三门峡市| 宝坻区| 巴林右旗| 济南市| 隆昌县| 武汉市| 天长市| 江安县| 阳信县| 庆安县| 阳谷县| 乾安县| 油尖旺区| 封开县| 临安市| 吉水县| 武陟县| 新巴尔虎右旗| 洱源县| 金门县| 屏南县| 无锡市| 太康县| 新闻| 合川市| 当涂县| 垣曲县| 毕节市| 九寨沟县| 宜兴市| 镇江市| 平山县|