MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / GetData

Method GetData

GTE/Samples/Physics/BallHill/PhysicsModule.cpp:61–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void PhysicsModule::GetData(Vector4<float>& center, Matrix4x4<float>& incrRot) const
62{
63 // Position is a point exactly on the hill.
64 Vector4<float> position;
65 position[0] = a1 * mState[0];
66 position[1] = a2 * mState[2];
67 position[2] = a3 - mState[0] * mState[0] - mState[2] * mState[2];
68 position[3] = 1.0f;
69
70 // Lift this point off the hill in the normal direction by the radius of
71 // the ball so that the ball just touches the hill. The hill is
72 // implicitly specified by F(x,y,z) = z - [a3 - (x/a1)^2 - (y/a2)^2]
73 // where (x,y,z) is the position on the hill. The gradient of F is a
74 // normal vector, Grad(F) = (2*x/a1^2,2*y/a2^2,1).
75 Vector4<float> normal;
76 normal[0] = 2.0f * position[0] / mAux[0];
77 normal[1] = 2.0f * position[1] / mAux[1];
78 normal[2] = 1.0f;
79 normal[3] = 0.0f;
80 Normalize(normal);
81
82 center = position + radius * normal;
83
84 // Let the ball rotate as it rolls down hill. The axis of rotation is
85 // the perpendicular to hill normal and ball velocity. The angle of
86 // rotation from the last position is A = speed*deltaTime/radius.
87 Vector4<float> velocity;
88 velocity[0] = a1 * mState[1];
89 velocity[1] = a1 * mState[3];
90 velocity[2] = -2.0f * (velocity[0] * mState[0] + velocity[1] * mState[2]);
91 velocity[3] = 0.0f;
92
93 float speed = Normalize(velocity);
94 float angle = speed * mSolver->GetTDelta() / radius;
95 Vector4<float> axis = UnitCross(normal, velocity);
96 incrRot = Rotation<4,float>(AxisAngle<4, float>(axis, angle));
97}
98
99float PhysicsModule::GetHeight(float x, float y) const
100{

Callers 15

CreateEighthSphereMethod · 0.45
GpuShortestPathMethod · 0.45
OnIdleMethod · 0.45
CreateSceneMethod · 0.45
CreateSceneMethod · 0.45
CreateSceneMethod · 0.45
CreateSceneMethod · 0.45
OnIdleMethod · 0.45
OnIdleMethod · 0.45
CreateMeshCubesMethod · 0.45
CreateMeshTetrahedraMethod · 0.45
CreateImagesMethod · 0.45

Calls 3

UnitCrossFunction · 0.85
GetTDeltaMethod · 0.80
NormalizeFunction · 0.50

Tested by 1

GpuShortestPathMethod · 0.36