本文整理匯總了Python中Vector.norm方法的典型用法代碼示例。如果您正苦於以下問題:Python Vector.norm方法的具體用法?Python Vector.norm怎麽用?Python Vector.norm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Vector
的用法示例。
在下文中一共展示了Vector.norm方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testVectorOperators
# 需要導入模塊: import Vector [as 別名]
# 或者: from Vector import norm [as 別名]
def testVectorOperators() :
V = Vector([0.0, 1.0, 2.0])
W = Vector([3.0, 4.0, 5.0])
print V.dot(W)
print V.norm()
U = V.cross(W)
U.show()
示例2: oscillateCurve
# 需要導入模塊: import Vector [as 別名]
# 或者: from Vector import norm [as 別名]
def oscillateCurve( curve, start=0.0, end=1.0, freq=1.0, ease=0.5, strength=1.0 ):
""" Oscillates a given curve by moving each vertex in an alternating
direction based on the normal. This process takes place over the
range defined by "start" and "end" as percentages of arc length.
Oscillation eases to full strength as determined by the "ease" and
"strength" arguments. """
if(ease > (end-start)*0.5):
ease = (end-start)*0.5
if(start < end):
CVs = mc.getAttr( curve+".cv[*]" )
newCVs = findCVsInRange(curve, start, end)
for (I,U,L) in newCVs:
interp = (L-start)/(end-start)
osc = sin(freq*interp)
scale = pulse(start+ease, end, ease, L) # ease must be between 0 and 0.5
## Don't use Maya's normalized normal -- it flip flops with curvature so it's not good for oscillating offset
# normal = Vector(mc.pointOnCurve(curve, parameter=cv[1], normalizedNormal=True))
# if(normal.mag() == 0.0):
# print "Getting normal from up x tangent"
normal = Vector(0,1,0)**Vector(mc.pointOnCurve(curve, parameter=U, tangent=True))
normal = normal.norm()
pos = Vector(CVs[I])
pos = pos+normal*scale*strength*osc
CVs[I] = pos.asTuple()
for i,cv in enumerate(CVs):
mc.setAttr(curve+".cv[%d]"%i, cv[0], cv[1], cv[2])
return curve
示例3: noiseCurve
# 需要導入模塊: import Vector [as 別名]
# 或者: from Vector import norm [as 別名]
def noiseCurve( curve, start=0.0, end=1.0, freq=1.0, ease=0.5, strength=1.0 ):
""" Adds noise to a given curve by moving each vertex with Perlin
noise based on the normal. This process takes place over the
range defined by "start" and "end" as percentages of arc length.
Noise eases to full strength as determined by the "ease" and
"strength" arguments. """
if(ease > (end-start)*0.5): # ease must be between 0 and 0.5
ease = (end-start)*0.5
if(start < end):
CVs = mc.getAttr( curve+".cv[*]" )
newCVs = findCVsInRange(curve, start, end)
for (I,U,L) in newCVs:
interp = (L-start)/(end-start)
noiz = noise(freq*interp)
scale = pulse(start+ease, end, ease, L)
normal = Vector(0,1,0)**Vector(mc.pointOnCurve(curve, parameter=U, tangent=True))
normal = normal.norm()
pos = Vector(CVs[I])
pos = pos+normal*scale*strength*noiz
CVs[I] = pos.asTuple()
for i,cv in enumerate(CVs):
print(curve+".cv[%d]"%cv[0], cv[0], cv[1], cv[2])
mc.setAttr(curve+".cv[%d]"%i, cv[0], cv[1], cv[2])
示例4: Vector
# 需要導入模塊: import Vector [as 別名]
# 或者: from Vector import norm [as 別名]
from Vector import *
a = Vector(3, [2,8,-1.0])
b = Vector(3, [1,1,2])
c = a.norm()
print(c)
v0 = Vector(2,[3,1])
v1 = Vector(2,[2,2])
W = GrammSchmidt([v0,v1])
print(W[0])
print(W[1])
print(W[0].inner(W[1]))
print(W[0].norm())