当前位置: 首页>>代码示例>>Python>>正文


Python Vector.dotProduct方法代码示例

本文整理汇总了Python中Vector.dotProduct方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.dotProduct方法的具体用法?Python Vector.dotProduct怎么用?Python Vector.dotProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector的用法示例。


在下文中一共展示了Vector.dotProduct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: elasticCollision

# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import dotProduct [as 别名]
 def elasticCollision(self,o):
     """
     Elastic collision with another object
     This changes the velocity of both objects
     """
     normal = Vector( o.x - self.x, self.y - o.y )
     normal.setVector( normal.getUnitVector() )
     tangent = Vector( -normal.y, normal.x )
     
     m1 = self.mass
     m2 = o.mass
     
     v1n = normal.dotProduct( self.velocity )
     v1t = tangent.dotProduct( self.velocity )
     v2n = normal.dotProduct( o.velocity )
     v2t = tangent.dotProduct( o.velocity )        
     
     v1tPrime = v1t
     v2tPrime = v2t
     
     v1nPrime = (v1n*(m1-m2)+v2n*m2*2)/(m1+m2)
     v2nPrime = (v2n*(m2-m1)+v1n*m1*2)/(m1+m2)
     
     vectorV1nPrime = normal.multiply(v1nPrime)
     vectorV1tPrime = tangent.multiply(v1tPrime)
     vectorV2nPrime = normal.multiply(v2nPrime)
     vectorV2tPrime = tangent.multiply(v2tPrime)
     
     self.velocity = vectorV1nPrime.add(vectorV1tPrime).multiply(ELASTIC_COLLISION_DAMPENING)
     o.velocity = vectorV2nPrime.add(vectorV2tPrime).multiply(ELASTIC_COLLISION_DAMPENING)
开发者ID:blendmaster,项目名称:Rokkit-Tanx,代码行数:32,代码来源:PhysicsObject.py

示例2: Specular

# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import dotProduct [as 别名]
def Specular(aNormal,aTrianglePoint):
  eyeVector = [cameraX - aTrianglePoint[X],
               cameraY - aTrianglePoint[Y],
               cameraZ - aTrianglePoint[Z],
               1.0     - aTrianglePoint[3]]

  eyeVector = Vector.normalize(eyeVector)
 
  lightVec = [lightPoint[X] - aTrianglePoint[X],
              lightPoint[Y] - aTrianglePoint[Y],
              lightPoint[Z] - aTrianglePoint[Z],
              lightPoint[W] - aTrianglePoint[W]]
  
  lightVec = Vector.normalize(lightVec)

  #caculate the half vector
  H = [lightVec[X] + eyeVector[X],
       lightVec[Y] + eyeVector[Y],
       lightVec[Z] + eyeVector[Z],
       lightVec[W] + eyeVector[W]]

  #now normalize and dot the half with the normal vec,
  #use the shininess constant defined in IncludesAndConstants.py
  H = Vector.normalize(H)
  d = Vector.dotProduct(aNormal,H)
  return math.pow(max(d,0),shininess)
开发者ID:LloydGhettoWolf,项目名称:Python-Renderer,代码行数:28,代码来源:Lighting.py

示例3: Diffuse

# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import dotProduct [as 别名]
def Diffuse(aNormal,aTrianglePoint):
  lightVec = [ lightPoint[X] - aTrianglePoint[X],
               lightPoint[Y] - aTrianglePoint[Y],
               lightPoint[Z] - aTrianglePoint[Z],
               lightPoint[W] - aTrianglePoint[W]]

  lightVec = Vector.normalize(lightVec)
  #print(lightVec[X],lightVec[Y],lightVec[Z])
  #print(Vector.length(lightVec))
  aNormal = Vector.normalize(aNormal)

  return max(Vector.dotProduct(lightVec,aNormal),0)  
开发者ID:LloydGhettoWolf,项目名称:Python-Renderer,代码行数:14,代码来源:Lighting.py

示例4: TestForCull

# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import dotProduct [as 别名]
def TestForCull(aTriangle):
  camVector = [IncludesAndConstants.lookPointX - IncludesAndConstants.cameraX,
               IncludesAndConstants.lookPointY - IncludesAndConstants.cameraY,
               IncludesAndConstants.lookPointZ - IncludesAndConstants.cameraZ,0]

  camVector = Vector.normalize(camVector)

  normal = [aTriangle.normal[X],aTriangle.normal[Y],aTriangle.normal[Z],0]
  normal = Vector.normalize(normal)

  if Vector.dotProduct(camVector,normal) <= 0.0:
    return True
  else:
    return False
开发者ID:LloydGhettoWolf,项目名称:Python-Renderer,代码行数:16,代码来源:Triangle.py

示例5:

# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import dotProduct [as 别名]
lookVector = Vector.normalize(lookVector)

rightVector = Vector.crossProduct([0,1,0,0],lookVector)
rightVector = Vector.normalize(rightVector)

upVector = Vector.crossProduct(lookVector,rightVector)
upVector = Vector.normalize(upVector)


CameraPos = [cameraX,cameraY,cameraZ,1]


viewMatrix = [[rightVector[X],upVector[X],lookVector[X],0],
              [rightVector[Y],upVector[Y],lookVector[Y],0],
              [rightVector[Z],upVector[Z],lookVector[Z],0],
              [-(Vector.dotProduct(CameraPos,rightVector)),-(Vector.dotProduct(CameraPos,upVector)),-(Vector.dotProduct(CameraPos,lookVector)),1]]


ScreenMatrix = [[ViewportWidth/2,0,0,0],
                [0,-ViewportHeight/2,0,0],
		[0,0,1,0],
		[ViewportWidth/2,ViewportHeight/2,0,1]]

#PROJECTION MATRIX

yScale = (math.cos(FOV/2)/math.sin(FOV/2))
xScale = yScale / aspectRatio
zf = farPlane/(farPlane - nearPlane)
zn = -(nearPlane * farPlane)/(farPlane-nearPlane)

projectionMatrix = [[xScale,0,0,0],
开发者ID:LloydGhettoWolf,项目名称:Python-Renderer,代码行数:33,代码来源:AppInfo.py


注:本文中的Vector.dotProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。