Changeset 384

Show
Ignore:
Timestamp:
07/23/09 13:34:15 (12 months ago)
Author:
laura
Message:

tree

Location:
branches/adaptare/trunk/hfall
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • branches/adaptare/trunk/hfall/Engine/Camera.py

    r377 r384  
    170170            normal = VA.crossProduct(VD) 
    171171            normal.normalize() 
    172             plane = Plane(cameraPosition, normal) 
    173             return plane 
     172            return Plane(cameraPosition, normal) 
    174173         
    175174        if string == 'right': 
    176175            normal = VB.crossProduct(VC) 
    177176            normal.normalize() 
    178             plane = Plane(cameraPosition, normal) 
    179             return plane 
     177            return Plane(cameraPosition, normal) 
    180178         
    181179        if string == 'top': 
    182180            normal = VA.crossProduct(VB) 
    183181            normal.normalize() 
    184             plane = Plane(cameraPosition, normal) 
    185             return plane 
     182            return Plane(cameraPosition, normal) 
    186183         
    187184        if string == 'bottom': 
    188185            normal == VC.crossProduct(VD) 
    189186            normal.normalize() 
    190             plane = Plane(cameraPosition, normal) 
    191             return plane 
     187            return Plane(cameraPosition, normal) 
    192188         
    193189        if string == 'near': 
    194             plane = Plane(axPoint, self.viewVector()) 
    195             return plane 
     190            return Plane(axPoint, self.viewVector()) 
    196191         
    197192        if string == 'far': 
    198             plane = Plane(auxPoint, -self.viewVector()) 
    199             return plane 
    200  
     193            return Plane(auxPoint, -self.viewVector()) 
  • branches/adaptare/trunk/hfall/Engine/Object.py

    r335 r384  
    9898                            
    9999        self.projection *= m 
    100  
    101          
  • branches/adaptare/trunk/hfall/Quaternion.py

    r377 r384  
    253253    @staticmethod 
    254254    def dot(Q1, Q2): 
    255         if isinstance(Q1, Quaternion): 
    256             if isinstance(Q2, Quaternion): 
    257                 return Q1.x * Q2.x + Q1.y * Q2.y + Q1.z * Q2.z + Q1.w * Q2.w 
    258             else: 
    259                 raise TypeError("Invalid argument") 
    260         else: 
    261             raise TypeError("Invalid argument") 
     255        return Q1.x * Q2.x + Q1.y * Q2.y + Q1.z * Q2.z + Q1.w * Q2.w 
    262256 
    263257    @staticmethod 
     
    266260        Linearly interpolate each component, then normalize the Quaternion 
    267261        """ 
    268         if isinstance(Q1, Quaternion): 
    269             if isinstance(Q2, Quaternion): 
    270                 return (Q1 * (1-t) + Q2 * t).normalize() 
    271             else: 
    272                 raise TypeError("Invalid argument") 
    273         else: 
    274             raise TypeError("Invalid argument") 
    275          
     262        return (Q1 * (1-t) + Q2 * t).normalize()         
    276263 
    277264    @staticmethod 
     
    279266        """ 
    280267        Spherical linear interpolation 
    281         """ 
    282         if isinstance(Q1, Quaternion): 
    283             if isinstance(Q2, Quaternion): 
    284              
    285                 dot = Quaternion.dot(Q1, Q2) 
    286                 if dot < 0: 
    287                     dot = -dot 
    288                     Q3 = -Q2 
    289                 else: 
    290                     Q3 = Q2 
     268        """            
     269        dot = Quaternion.dot(Q1, Q2) 
     270        if dot < 0: 
     271            dot = -dot 
     272            Q3 = -Q2 
     273        else: 
     274            Q3 = Q2 
    291275                 
    292                 if dot < 0.95: 
    293                     angle = math.acos(dot) 
    294                     w1 = math.sin(angle * (1-t)) / math.sin(angle) 
    295                     w2 = math.sin(angle * t) / math.sin(angle) 
    296                     return Q1 * w1 + Q3 * w2 
    297                 else: 
    298                 # The angle is small. We use linear interpolation 
    299                     Quaternion.LERP(Q1, Q3, t) 
    300                      
    301             else: 
    302                 raise TypeError("Invalid argument") 
    303         else: 
    304             raise TypeError("Invalid argument")             
     276        if dot < 0.95: 
     277            angle = math.acos(dot) 
     278            w1 = math.sin(angle * (1-t)) / math.sin(angle) 
     279            w2 = math.sin(angle * t) / math.sin(angle) 
     280            return Q1 * w1 + Q3 * w2 
     281        else: 
     282        # The angle is small. We use linear interpolation 
     283            Quaternion.LERP(Q1, Q3, t)