Panda3D
|
This is the base class for all three-component vectors and points. More...
#include "lvecBase3.h"
Public Types | |
enum | { num_components = 3, is_int = 0 } |
typedef const float * | const_iterator |
typedef LSimpleMatrix< float, 1, 3 > | EVector3 |
typedef const float * | iterator |
typedef float | numeric_type |
Public Member Functions | |
LVecBase3f (const LVecBase3f ©) | |
LVecBase3f (float fill_value) | |
LVecBase3f (float x, float y, float z) | |
LVecBase3f (const LVecBase2f ©, float z) | |
LVecBase3f (const EVector3 &v) | |
size_t | add_hash (size_t hash) const |
Adds the vector into the running hash. More... | |
size_t | add_hash (size_t hash, float threshold) const |
Adds the vector into the running hash. More... | |
void | add_to_cell (int i, float value) |
void | add_x (float value) |
void | add_y (float value) |
void | add_z (float value) |
bool | almost_equal (const LVecBase3f &other, float threshold) const |
Returns true if two vectors are memberwise equal within a specified tolerance. More... | |
bool | almost_equal (const LVecBase3f &other) const |
Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type. More... | |
iterator | begin () |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style. More... | |
const_iterator | begin () const |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style. More... | |
int | compare_to (const LVecBase3f &other) const |
This flavor of compare_to uses a default threshold value based on the numeric type. More... | |
int | compare_to (const LVecBase3f &other, float threshold) const |
Sorts vectors lexicographically, componentwise. More... | |
void | componentwise_mult (const LVecBase3f &other) |
LVecBase3f | cross (const LVecBase3f &other) const |
void | cross_into (const LVecBase3f &other) |
float | dot (const LVecBase3f &other) const |
iterator | end () |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style. More... | |
const_iterator | end () const |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style. More... | |
void | fill (float fill_value) |
Sets each element of the vector to the indicated fill_value. More... | |
LVecBase3f | fmax (const LVecBase3f &other) const |
LVecBase3f | fmin (const LVecBase3f &other) const |
void | generate_hash (ChecksumHashGenerator &hashgen) const |
Adds the vector to the indicated hash generator. More... | |
void | generate_hash (ChecksumHashGenerator &hashgen, float threshold) const |
Adds the vector to the indicated hash generator. More... | |
float | get_cell (int i) const |
const float * | get_data () const |
Returns the address of the first of the three data elements in the vector. More... | |
size_t | get_hash () const |
Returns a suitable hash for phash_map. More... | |
size_t | get_hash (float threshold) const |
Returns a suitable hash for phash_map. More... | |
int | get_num_components () const |
Returns the number of elements in the vector, three. More... | |
LVecBase3f | get_standardized_hpr () const |
Try to un-spin the hpr to a standard form. More... | |
float | get_x () const |
LVecBase2f | get_xy () const |
Returns a 2-component vector that shares just the first two components of this vector. More... | |
LVecBase2f | get_xz () const |
Returns a 2-component vector that shares just the first and last components of this vector. More... | |
float | get_y () const |
LVecBase2f | get_yz () const |
Returns a 2-component vector that shares just the last two components of this vector. More... | |
float | get_z () const |
bool | is_nan () const |
Returns true if any component of the vector is not-a-number, false otherwise. More... | |
float | length () const |
Returns the length of the vector, by the Pythagorean theorem. More... | |
float | length_squared () const |
Returns the square of the vector's length, cheap and easy. More... | |
bool | normalize () |
Normalizes the vector in place. More... | |
LVecBase3f | normalized () const |
Normalizes the vector and returns the normalized vector as a copy. More... | |
bool | operator!= (const LVecBase3f &other) const |
LVecBase3f | operator* (float scalar) const |
void | operator*= (float scalar) |
LVecBase3f | operator+ (const LVecBase3f &other) const |
void | operator+= (const LVecBase3f &other) |
LVecBase3f | operator- () const |
LVecBase3f | operator- (const LVecBase3f &other) const |
void | operator-= (const LVecBase3f &other) |
LVecBase3f | operator/ (float scalar) const |
void | operator/= (float scalar) |
bool | operator< (const LVecBase3f &other) const |
This performs a lexicographical comparison. More... | |
LVecBase3f & | operator= (const LVecBase3f ©) |
LVecBase3f & | operator= (float fill_value) |
bool | operator== (const LVecBase3f &other) const |
float | operator[] (int i) const |
float & | operator[] (int i) |
void | output (ostream &out) const |
LVecBase3f | project (const LVecBase3f &onto) const |
Returns a new vector representing the projection of this vector onto another one. More... | |
void | read_datagram (DatagramIterator &source) |
Reads the vector from the Datagram using get_stdfloat(). More... | |
void | read_datagram_fixed (DatagramIterator &source) |
Reads the vector from the Datagram using get_float32() or get_float64(). More... | |
void | set (float x, float y, float z) |
void | set_cell (int i, float value) |
void | set_x (float value) |
void | set_y (float value) |
void | set_z (float value) |
void | write_datagram (Datagram &destination) const |
Writes the vector to the Datagram using add_stdfloat(). More... | |
void | write_datagram_fixed (Datagram &destination) const |
Writes the vector to the Datagram using add_float32() or add_float64(), depending on the type of floats in the vector, regardless of the setting of Datagram::set_stdfloat_double(). More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static int | size () |
Returns 3: the number of components of a LVecBase3. More... | |
static const LVecBase3f & | unit_x () |
Returns a unit X vector. More... | |
static const LVecBase3f & | unit_y () |
Returns a unit Y vector. More... | |
static const LVecBase3f & | unit_z () |
Returns a unit Z vector. More... | |
static const LVecBase3f & | zero () |
Returns a zero-length vector. More... | |
Public Attributes | |
EVector3 | _v |
This is the base class for all three-component vectors and points.
Definition at line 105 of file lvecBase3.h.
|
inline |
Adds the vector into the running hash.
Definition at line 975 of file lvecBase3.h.
References integer_hash< Key, Compare >::add_hash().
|
inline |
Adds the vector into the running hash.
Definition at line 1046 of file lvecBase3.h.
References floating_point_hash< Key >::add_hash().
|
inline |
Returns true if two vectors are memberwise equal within a specified tolerance.
Definition at line 1280 of file lvecBase3.h.
Referenced by NurbsCurveResult::adaptive_sample(), EggSaver::add_node(), BoundingLine::as_bounding_line(), ParametricCurve::convert_to_hermite(), CollisionSphere::get_test_pcollector(), ACMatrixSwitchType::output_value(), RopeNode::reset_bound(), BillboardEffect::safe_to_transform(), FltToEggLevelState::set_transform(), QtessSurface::tesselate_auto(), ColorScaleAttrib::write_datagram(), and LinearFrictionForce::~LinearFrictionForce().
|
inline |
Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type.
Definition at line 1294 of file lvecBase3.h.
|
inline |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
Definition at line 658 of file lvecBase3.h.
|
inline |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
Definition at line 680 of file lvecBase3.h.
|
inline |
This flavor of compare_to uses a default threshold value based on the numeric type.
Definition at line 940 of file lvecBase3.h.
Referenced by XFileMaterial::apply_to_egg(), and BillboardEffect::safe_to_transform().
|
inline |
Sorts vectors lexicographically, componentwise.
Returns a number less than 0 if this vector sorts before the other one, greater than zero if it sorts after, 0 if they are equivalent (within the indicated tolerance).
Definition at line 1015 of file lvecBase3.h.
|
inline |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
Definition at line 669 of file lvecBase3.h.
|
inline |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
Definition at line 691 of file lvecBase3.h.
|
inline |
Sets each element of the vector to the indicated fill_value.
This is particularly useful for initializing to zero.
Definition at line 703 of file lvecBase3.h.
|
inline |
Adds the vector to the indicated hash generator.
Definition at line 993 of file lvecBase3.h.
References ChecksumHashGenerator::add_int().
|
inline |
Adds the vector to the indicated hash generator.
Definition at line 1061 of file lvecBase3.h.
References ChecksumHashGenerator::add_fp().
|
inline |
Returns the address of the first of the three data elements in the vector.
The remaining elements occupy the next positions consecutively in memory.
Definition at line 637 of file lvecBase3.h.
Referenced by DXGraphicsStateGuardian9::bind_light(), Shader::get_language(), and QtessSurface::tesselate_auto().
|
inline |
Returns a suitable hash for phash_map.
Definition at line 964 of file lvecBase3.h.
|
inline |
Returns a suitable hash for phash_map.
Definition at line 1035 of file lvecBase3.h.
|
inline |
Returns the number of elements in the vector, three.
Definition at line 647 of file lvecBase3.h.
Referenced by Shader::get_language().
|
inline |
Try to un-spin the hpr to a standard form.
Like all standards, someone decides between many arbitrary possible standards. This function assumes that 0 and 360 are the same, as is 720 and -360. Also 180 and -180 are the same. Another example is -90 and 270. Each element will be in the range -180.0 to 179.99999. The original usage of this function is for human readable output.
It doesn't work so well for asserting that foo_hpr is roughly equal to bar_hpr. Try using LQuaternionf::is_same_direction() for that. See Also: get_standardized_rotation, LQuaternion::is_same_direction
Definition at line 926 of file lvecBase3.h.
|
inline |
Returns a 2-component vector that shares just the first two components of this vector.
Definition at line 562 of file lvecBase3.h.
|
inline |
Returns a 2-component vector that shares just the first and last components of this vector.
Definition at line 573 of file lvecBase3.h.
|
inline |
Returns a 2-component vector that shares just the last two components of this vector.
Definition at line 584 of file lvecBase3.h.
|
inline |
Returns true if any component of the vector is not-a-number, false otherwise.
Definition at line 464 of file lvecBase3.h.
Referenced by IntersectionBoundingVolume::add_component(), PhysxActor::add_force(), PhysxActor::add_force_at_local_pos(), PhysxActor::add_force_at_pos(), PhysicsObject::add_impact(), PhysicsObject::add_impulse(), PhysxActor::add_local_force(), PhysxActor::add_local_force_at_local_pos(), PhysxActor::add_local_force_at_pos(), PhysicsObject::add_local_impact(), PhysicsObject::add_local_impulse(), PhysxActor::add_local_torque(), PhysxActor::add_torque(), BoundingBox::as_bounding_box(), BoundingLine::as_bounding_line(), BoundingSphere::as_bounding_sphere(), PhysxCloth::attach_vertex_to_global_pos(), PhysxCloth::attach_vertex_to_shape(), BoundingBox::BoundingBox(), BoundingSphere::BoundingSphere(), PhysxBounds3::bounds_of_obb(), PhysxUtilLib::box_box_intersect(), BulletTriangleMeshShape::BulletTriangleMeshShape(), PhysxCapsule::compute_direction(), PhysxSegment::compute_direction(), PhysxCapsule::compute_point(), PhysxSegment::compute_point(), PhysxBounds3::contain(), PhysxSphere::contains(), UnionBoundingVolume::filter_intersection(), PfmFile::forward_distort(), BulletSoftBodyNode::get_closest_node_index(), BulletRigidBodyNode::get_inertia(), PhysxActor::get_local_point_velocity(), PhysxActor::get_point_velocity(), PhysxBounds3::include(), PfmVizzer::make_displacement(), PhysxActor::move_global_pos(), PhysxUtilLib::point_obb_sqr_dist(), PhysxUtilLib::ray_aabb_intersect(), PhysxUtilLib::ray_capsule_intersect(), PhysxUtilLib::ray_obb_intersect(), PhysxUtilLib::ray_sphere_intersect(), PhysxUtilLib::ray_tri_intersect(), BulletWorld::remove_constraint(), PhysicsObject::reset_position(), BulletBodyNode::safe_to_flatten_below(), PhysxUtilLib::segment_aabb_intersect(), PhysxUtilLib::segment_box_intersect(), PhysxUtilLib::segment_obb_intersect(), PhysxBounds3::set(), BulletHingeConstraint::set_axis(), PhysxSphere::set_center(), PhysxBox::set_center(), PhysxBounds3::set_center_extents(), BulletWheel::set_chassis_connection_point_cs(), CollisionEntry::set_contact_normal(), CollisionEntry::set_contact_pos(), PhysxBoxForceFieldShapeDesc::set_dimensions(), PhysxBoxShapeDesc::set_dimensions(), PhysxRay::set_direction(), CLerpNodePathInterval::set_end_hpr(), CLerpNodePathInterval::set_end_pos(), CLerpNodePathInterval::set_end_quat(), CLerpNodePathInterval::set_end_scale(), CLerpNodePathInterval::set_end_shear(), PhysxBox::set_extents(), PhysxCloth::set_external_acceleration(), PhysxD6JointDesc::set_flag(), Lens::set_frustum_from_corners(), PhysxActor::set_global_pos(), PhysxController::set_global_speed(), PhysxSceneDesc::set_gravity(), PhysxScene::set_gravity(), CollisionEntry::set_interior_point(), PhysxController::set_local_speed(), PhysxBounds3::set_max(), PhysxBounds3::set_min(), PhysxForceFieldShapeDesc::set_name(), PhysxRay::set_origin(), PhysxCapsule::set_origin_direction(), PhysxSegment::set_origin_direction(), PhysxSegment::set_p0(), PhysxCapsule::set_p0(), PhysxSegment::set_p1(), PhysxCapsule::set_p1(), PhysxPlaneShapeDesc::set_plane(), PfmFile::set_point3(), PhysicsObject::set_position(), CLerpNodePathInterval::set_start_hpr(), CLerpNodePathInterval::set_start_pos(), CLerpNodePathInterval::set_start_scale(), CLerpNodePathInterval::set_start_shear(), CollisionEntry::set_surface_normal(), CollisionEntry::set_surface_point(), PhysxSphericalJointDesc::set_swing_axis(), PhysxShapeDesc::set_trigger(), PhysicsObject::set_velocity(), Lens::set_view_hpr(), Lens::set_view_vector(), BulletWheel::set_wheel_axle_cs(), BulletWheel::set_wheel_direction_cs(), PhysxCloth::set_wind_acceleration(), PhysxUtilLib::sweep_box_box(), PhysxUtilLib::sweep_box_capsule(), PhysxUtilLib::sweep_box_sphere(), PhysxUtilLib::sweep_capsule_capsule(), PhysxUtilLib::sweep_sphere_capsule(), PhysxUtilLib::swept_spheres_intersect(), PhysxBounds3::transform(), PhysxUtilLib::tri_box_intersect(), LinearEulerIntegrator::~LinearEulerIntegrator(), and LinearForce::~LinearForce().
|
inline |
Returns the length of the vector, by the Pythagorean theorem.
Definition at line 766 of file lvecBase3.h.
Referenced by AIBehaviors::accumulate_force(), PhysicsObject::add_impact(), Arrival::arrival_activate(), AIBehaviors::calculate_prioritized(), Arrival::do_arrival(), Evade::do_evade(), Flee::do_flee(), AIBehaviors::do_flock(), ObstacleAvoidance::do_obstacle_avoidance(), Evade::evade_activate(), Flee::flee_activate(), SmoothMover::get_latest_position(), CollisionInvSphere::get_test_pcollector(), CollisionSphere::get_test_pcollector(), CollisionTube::get_test_pcollector(), CollisionPolygon::get_test_pcollector(), AIBehaviors::is_conflict(), ObstacleAvoidance::obstacle_detection(), RopeNode::reset_bound(), LQuaternionf::set_from_axis_angle_rad(), LQuaterniond::set_from_axis_angle_rad(), MeshDrawer::stream(), QtessSurface::tesselate_auto(), AICharacter::update(), CMotionTrail::update_motion_trail(), CollisionPolygon::verify_points(), SceneGraphAnalyzer::write(), LODNode::xform(), PGFrameStyle::xform(), LinearCylinderVortexForce::~LinearCylinderVortexForce(), LinearEulerIntegrator::~LinearEulerIntegrator(), and LinearFrictionForce::~LinearFrictionForce().
|
inline |
Returns the square of the vector's length, cheap and easy.
Definition at line 749 of file lvecBase3.h.
Referenced by NurbsCurveResult::adaptive_sample(), CollisionHandlerHighestEvent::add_entry(), GeomPrimitive::calc_tight_bounds(), Geom::get_next_modified(), CollisionSphere::get_test_pcollector(), CollisionBox::get_test_pcollector(), CollisionParabola::get_test_pcollector(), CollisionPolygon::get_test_pcollector(), Lens::is_orthographic(), ObstacleAvoidance::obstacle_detection(), project(), LVecBase3d::project(), LVecBase3i::project(), RopeNode::reset_bound(), CollisionSegment::set_from_lens(), Lens::set_frustum_from_corners(), and ParametricCurveCollection::unregister_drawer().
|
inline |
Normalizes the vector in place.
Returns true if the vector was normalized, false if it was a zero-length vector.
Definition at line 783 of file lvecBase3.h.
Referenced by AIBehaviors::accumulate_force(), NurbsCurveResult::adaptive_sample(), CollisionHandlerFluidPusher::add_entry(), PhysicsObject::add_impact(), EggSaver::add_node(), Fog::adjust_to_camera(), TinyGraphicsStateGuardian::bind_light(), ColladaLoader::build_graph(), PfmFile::calc_tight_bounds(), AIBehaviors::calculate_prioritized(), GeomVertexData::clear_cache_stage(), ObjToEggConverter::convert_file(), ParametricCurve::convert_to_hermite(), PolylightEffect::cull_callback(), SpeedTreeNode::cull_callback(), Arrival::do_arrival(), NodePath::do_billboard_axis(), NodePath::do_billboard_point_eye(), NodePath::do_billboard_point_world(), Evade::do_evade(), AIBehaviors::do_flock(), ObstacleAvoidance::do_obstacle_avoidance(), Pursue::do_pursue(), Wander::do_wander(), MeshDrawer::explosion(), GraphicsStateGuardian::fetch_specified_part(), GraphicsStateGuardian::fetch_specified_value(), Flee::flee_activate(), BaseParticleEmitter::generate(), Texture::generate_normalization_cube_map(), HeightfieldTesselator::get_elevation(), GeoMipTerrain::get_normal(), CollisionPlane::get_test_pcollector(), CollisionSphere::get_test_pcollector(), CollisionInvSphere::get_test_pcollector(), CollisionTube::get_test_pcollector(), CollisionPolygon::get_test_pcollector(), AIBehaviors::is_conflict(), Lens::is_orthographic(), PfmVizzer::make_displacement(), GeoMipTerrain::make_slope_image(), ObstacleAvoidance::obstacle_detection(), CardMaker::reset(), RopeNode::reset_bound(), BillboardEffect::safe_to_transform(), MeshDrawer::stream(), AICharacter::update(), and LinearCylinderVortexForce::~LinearCylinderVortexForce().
|
inline |
Normalizes the vector and returns the normalized vector as a copy.
If the vector was a zero-length vector, a zero length vector will be returned.
Definition at line 805 of file lvecBase3.h.
|
inline |
This performs a lexicographical comparison.
It's of questionable mathematical meaning, but sometimes has a practical purpose for sorting unique vectors, especially in an STL container. Also see compare_to().
Definition at line 853 of file lvecBase3.h.
|
inline |
Returns a new vector representing the projection of this vector onto another one.
The resulting vector will be a scalar multiple of onto.
Definition at line 821 of file lvecBase3.h.
References length_squared().
|
inline |
Reads the vector from the Datagram using get_stdfloat().
Definition at line 1389 of file lvecBase3.h.
References DatagramIterator::get_int32(), and DatagramIterator::get_stdfloat().
Referenced by OccluderNode::complete_pointers(), STTransform::fillin(), CollisionRay::write_datagram(), CollisionSegment::write_datagram(), BillboardEffect::write_datagram(), CollisionSphere::write_datagram(), CollisionFloorMesh::write_datagram(), CollisionTube::write_datagram(), PolylightNode::write_datagram(), and CollisionBox::write_datagram().
|
inline |
Reads the vector from the Datagram using get_float32() or get_float64().
Definition at line 1346 of file lvecBase3.h.
References DatagramIterator::get_float32(), DatagramIterator::get_float64(), and DatagramIterator::get_int32().
|
inlinestatic |
Returns 3: the number of components of a LVecBase3.
Definition at line 453 of file lvecBase3.h.
Referenced by ObjToEggConverter::convert_file(), OccluderNode::output(), CollisionPolygon::write_datagram(), and CollisionPolygon::xform().
|
inlinestatic |
Returns a unit X vector.
Definition at line 392 of file lvecBase3.h.
|
inlinestatic |
Returns a unit Y vector.
Definition at line 402 of file lvecBase3.h.
|
inlinestatic |
Returns a unit Z vector.
Definition at line 412 of file lvecBase3.h.
|
inline |
Writes the vector to the Datagram using add_stdfloat().
This is appropriate when you want to write the vector using the standard width setting, especially when you are writing a bam file.
Definition at line 1371 of file lvecBase3.h.
References Datagram::add_int32(), and Datagram::add_stdfloat().
Referenced by STTransform::write_datagram(), CollisionRay::write_datagram(), CollisionSegment::write_datagram(), BillboardEffect::write_datagram(), CollisionSphere::write_datagram(), CollisionTube::write_datagram(), PolylightNode::write_datagram(), and CollisionBox::write_datagram().
|
inline |
Writes the vector to the Datagram using add_float32() or add_float64(), depending on the type of floats in the vector, regardless of the setting of Datagram::set_stdfloat_double().
This is appropriate when you want to write a fixed-width value to the datagram, especially when you are not writing a bam file.
Definition at line 1323 of file lvecBase3.h.
References Datagram::add_float32(), Datagram::add_float64(), and Datagram::add_int32().
|
inlinestatic |
Returns a zero-length vector.
Definition at line 382 of file lvecBase3.h.
Referenced by EggSaver::add_node(), XFileMaterial::apply_to_egg(), PfmFile::calc_min_max(), GeomVertexData::clear_cache_stage(), PNMImage::get_average_xel(), PStatMonitor::get_collector_color(), NurbsCurveInterface::get_cv_point(), GeomVertexReader::get_data3f(), DXGraphicsStateGuardian9::get_index_type(), CurveFitter::get_sample_hpr(), CurveFitter::get_sample_tangent(), CurveFitter::get_sample_xyz(), AnimChannelMatrixFixed::get_shear(), NodePath::get_tex_hpr(), NodePath::get_tex_pos(), AnimChannelMatrixFixed::get_value_no_scale_shear(), PNMImage::get_xel(), AnimChannelMatrixFixed::has_changed(), and AnimChannelMatrixFixed::write_datagram().