Skip to content

Instantly share code, notes, and snippets.

@pcote
Created April 24, 2012 08:14
Show Gist options
  • Save pcote/2477782 to your computer and use it in GitHub Desktop.
Save pcote/2477782 to your computer and use it in GitHub Desktop.
Sample Mesh Generation using Quaternions and BMesh
import bmesh
import bpy
from mathutils import Quaternion, Vector
bm = bmesh.new()
axis = (0,0,-1)
quats = [Quaternion(axis,x) for x in range(1,11)]
vecs = [quat * Vector((1,0,0)) for quat in quats]
for vec in vecs:
bm.verts.new([vec.x, vec.y, vec.z])
me = bpy.data.meshes.new("quat_mesh")
bm.to_mesh(me)
ob = bpy.data.objects.new("quat", me)
scn = bpy.context.scene
scn.objects.link(ob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment