tiny.linear.Vec3
Defined in tiny.linear.
API (27)
Actions
Public operations.
absaddclampLength:vshortened tomax_lengthwhen it is longer, elsevunchanged.crossdistancedistanceSqdotfromArrayinitlengthlengthSqlerp:aatt = 0andbatt = 1.maxmaxComponentminminComponentmul: Lane-wise product.negatenormalized: The unit vector alongv, or null when its length is at mostmin_lengthor is NaN.scalesplatsubtoArray
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: lib/linear/src/vector.zig:102
zig
pub const Vec3 = extern struct { x: f32 = 0, y: f32 = 0, z: f32 = 0, pub const zero: Vec3 = .{}; pub fn init(x: f32, y: f32, z: f32) Vec3 { return .{ .x = x, .y = y, .z = z }; } pub fn splat(value: f32) Vec3 { return .{ .x = value, .y = value, .z = value }; } pub fn fromArray(lanes: [3]f32) Vec3 { return .{ .x = lanes[0], .y = lanes[1], .z = lanes[2] }; } pub fn toArray(v: Vec3) [3]f32 { return .{ v.x, v.y, v.z }; } pub fn add(a: Vec3, b: Vec3) Vec3 { return .{ .x = a.x + b.x, .y = a.y + b.y, .z = a.z + b.z }; } pub fn sub(a: Vec3, b: Vec3) Vec3 { return .{ .x = a.x - b.x, .y = a.y - b.y, .z = a.z - b.z }; } /// Lane-wise product. pub fn mul(a: Vec3, b: Vec3) Vec3 { return .{ .x = a.x * b.x, .y = a.y * b.y, .z = a.z * b.z }; } pub fn scale(v: Vec3, s: f32) Vec3 { return .{ .x = v.x * s, .y = v.y * s, .z = v.z * s }; } pub fn negate(v: Vec3) Vec3 { return .{ .x = -v.x, .y = -v.y, .z = -v.z }; } pub fn dot(a: Vec3, b: Vec3) f32 { return a.x * b.x + a.y * b.y + a.z * b.z; } pub fn cross(a: Vec3, b: Vec3) Vec3 { return .{ .x = a.y * b.z - a.z * b.y, .y = a.z * b.x - a.x * b.z, .z = a.x * b.y - a.y * b.x, }; } pub fn lengthSq(v: Vec3) f32 { return v.dot(v); } pub fn length(v: Vec3) f32 { return @sqrt(v.lengthSq()); } pub fn distanceSq(a: Vec3, b: Vec3) f32 { return a.sub(b).lengthSq(); } pub fn distance(a: Vec3, b: Vec3) f32 { return @sqrt(a.distanceSq(b)); } /// The unit vector along `v`, or null when its length is at most /// `min_length` or is NaN. pub fn normalized(v: Vec3, min_length: f32) ?Vec3 { assert(min_length >= 0); const len = v.length(); if (!(len > min_length)) return null; return v.scale(1 / len); } /// `v` shortened to `max_length` when it is longer, else `v` unchanged. pub fn clampLength(v: Vec3, max_length: f32) Vec3 { assert(max_length >= 0); const len = v.length(); if (len > max_length) return v.scale(max_length / len); return v; } /// `a` at `t = 0` and `b` at `t = 1`. pub fn lerp(a: Vec3, b: Vec3, t: f32) Vec3 { return a.add(b.sub(a).scale(t)); } pub fn min(a: Vec3, b: Vec3) Vec3 { return .{ .x = @min(a.x, b.x), .y = @min(a.y, b.y), .z = @min(a.z, b.z) }; } pub fn max(a: Vec3, b: Vec3) Vec3 { return .{ .x = @max(a.x, b.x), .y = @max(a.y, b.y), .z = @max(a.z, b.z) }; } pub fn abs(v: Vec3) Vec3 { return .{ .x = @abs(v.x), .y = @abs(v.y), .z = @abs(v.z) }; } pub fn minComponent(v: Vec3) f32 { return @min(v.x, @min(v.y, v.z)); } pub fn maxComponent(v: Vec3) f32 { return @max(v.x, @max(v.y, v.z)); }};Source: lib/linear/src/root.zig:9
zig
pub const Vec3 = vector.Vec3;Complete caller list for Vec3.cross
9 direct callers.
fun.sdfii.src.audio.spatial.computePan[function] — private; no exact target atfun/sdfii/src/audio/spatial.zig:117in nearest public ownerfun.sdfii.src.audio.spatialfun.sdfii.src.engine.system.audio.runtime.validListener[function] — private; no exact target atfun/sdfii/src/engine/system/audio/runtime.zig:414in nearest public ownerfun.sdfii.src.engine.system.audio.runtimefun.sdfii.src.sdf.gradient.inverseOrientVec[function] — private; no exact target atfun/sdfii/src/sdf/gradient.zig:276in nearest public ownerfun.sdfii.src.sdf.gradientfun.sdfii.src.sdf.gradient.orientPoint[function] — private; no exact target atfun/sdfii/src/sdf/gradient.zig:265in nearest public ownerfun.sdfii.src.sdf.gradientfun.sdfii.src.sdf.vjp.accumulateSlotGradient[function] — private; no exact target atfun/sdfii/src/sdf/vjp.zig:775in nearest public ownerfun.sdfii.src.sdf.vjpfun.sdfii.src.sdf.vjp.orientPoint[function] — private; no exact target atfun/sdfii/src/sdf/vjp.zig:1375in nearest public ownerfun.sdfii.src.sdf.vjplib.linear.src.test.arithmeticDigest[function] — private source atlib/linear/src/test.zig:38in nearest public ownerlib.linear.src.testlib.linear.src.vector.test_cross_product_follows_the_right-hand_rule[function] — test source atlib/linear/src/vector.zig:342in nearest public ownerlib.linear.src.vectorlib.linear.src.vector.test_vector_arithmetic_evaluates_each_lane_exactly[function] — test source atlib/linear/src/vector.zig:327in nearest public ownerlib.linear.src.vector
Complete caller list for Vec3.fromArray
30 direct callers.
fun.sdfii.src.audio.late.BoundaryCache.meanBoundaryDistance[method] — private; no exact target atfun/sdfii/src/audio/late.zig:103in nearest public ownerfun.sdfii.src.audio.latefun.sdfii.src.engine.abi.physics.sdfii_quat_from_axis_angle[function] — private; no exact target atfun/sdfii/src/engine/abi/physics.zig:76in nearest public ownerfun.sdfii.src.engine.abi.physicsfun.sdfii.src.engine.abi.physics.sdfii_quat_integrate[function] — private; no exact target atfun/sdfii/src/engine/abi/physics.zig:96in nearest public ownerfun.sdfii.src.engine.abi.physicsfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_box_contact[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:135in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_distance[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:25in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_gradient[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:36in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_normal[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:78in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_parameter_gradient[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:58in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_point_contact[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:102in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_projection[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:90in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_raycast[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:154in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_sphere_contact[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:118in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.abi.query.sdfii_engine_core_query_sweep[function] — private; no exact target atfun/sdfii/src/engine/abi/query.zig:173in nearest public ownerfun.sdfii.src.engine.abi.queryfun.sdfii.src.engine.system.physics.vjp.evaluateFieldContact[function] — private; no exact target atfun/sdfii/src/engine/system/physics/vjp.zig:83in nearest public ownerfun.sdfii.src.engine.system.physics.vjpfun.sdfii.src.physics.articulation.proxyBody[function] — private; no exact target atfun/sdfii/src/physics/articulation.zig:28in nearest public ownerfun.sdfii.src.physics.articulationfun.sdfii.src.physics.ccd.applyCCD[function] — private; no exact target atfun/sdfii/src/physics/ccd.zig:20in nearest public ownerfun.sdfii.src.physics.ccdfun.sdfii.src.physics.contact.collectFieldContacts[function] — private; no exact target atfun/sdfii/src/physics/contact.zig:189in nearest public ownerfun.sdfii.src.physics.contactfun.sdfii.src.physics.contact.computeBatchContactForces[function] — private; no exact target atfun/sdfii/src/physics/contact.zig:336in nearest public ownerfun.sdfii.src.physics.contactfun.sdfii.src.query.contact.test_box_contact:_fixture_mixed_scenes[function] — test; no exact target atfun/sdfii/src/query/contact.zig:529in nearest public ownerfun.sdfii.src.query.contactfun.sdfii.src.query.contact.test_point_contact:_fixture_invariants[function] — test; no exact target atfun/sdfii/src/query/contact.zig:473in nearest public ownerfun.sdfii.src.query.contactfun.sdfii.src.query.lane.meshHit[function] — private; no exact target atfun/sdfii/src/query/lane.zig:109in nearest public ownerfun.sdfii.src.query.lanefun.sdfii.src.query.normal.test_normal:_fixture_normals_match_gradient_within_1e-3_rad[function] — test; no exact target atfun/sdfii/src/query/normal.zig:317in nearest public ownerfun.sdfii.src.query.normalfun.sdfii.src.query.normal.test_projection:_fixture_points_converge_within_1e-4[function] — test; no exact target atfun/sdfii/src/query/normal.zig:367in nearest public ownerfun.sdfii.src.query.normalfun.sdfii.src.query.raycast.runFixtureRaycast[function] — private; no exact target atfun/sdfii/src/query/raycast.zig:342in nearest public ownerfun.sdfii.src.query.raycastfun.sdfii.src.query.service.queryGradientAtRevision[method] — private; no exact target atfun/sdfii/src/query/service.zig:206in nearest public ownerfun.sdfii.src.query.servicefun.sdfii.src.query.test.corpus_tests.runFixture[function] — private; no exact target atfun/sdfii/src/query/test.zig:83in nearest public ownerfun.sdfii.src.query.testfun.sdfii.src.rig.test.test_rig_slot_bindings_mutate_a_differentiable_program_without_recompiling[function] — test; no exact target atfun/sdfii/src/rig/test.zig:16in nearest public ownerfun.sdfii.src.rig.testfun.sdfii.src.validation.review.physics.evaluateFieldContact[function] — private; no exact target atfun/sdfii/src/validation/review/physics.zig:126in nearest public ownerfun.sdfii.src.validation.review.physicsfun.sdfii.src.validation.review.physics.runTrajectoryMatch[function] — private; no exact target atfun/sdfii/src/validation/review/physics.zig:158in nearest public ownerfun.sdfii.src.validation.review.physicslib.linear.src.vector.test_vector_arithmetic_evaluates_each_lane_exactly[function] — test source atlib/linear/src/vector.zig:327in nearest public ownerlib.linear.src.vector
Complete caller list for Vec3.init
7 direct callers.
lib.linear.src.vector.test_clampLength_shortens_only_longer_vectors[function] — test source atlib/linear/src/vector.zig:365in nearest public ownerlib.linear.src.vectorlib.linear.src.vector.test_cross_product_follows_the_right-hand_rule[function] — test source atlib/linear/src/vector.zig:342in nearest public ownerlib.linear.src.vectorlib.linear.src.vector.test_homogeneous_vectors_carry_their_w_lane[function] — test source atlib/linear/src/vector.zig:379in nearest public ownerlib.linear.src.vectorlib.linear.src.vector.test_normalized_multiplies_by_the_reciprocal_length[function] — test source atlib/linear/src/vector.zig:359in nearest public ownerlib.linear.src.vectorlib.linear.src.vector.test_normalized_returns_null_at_or_below_the_minimum_length[function] — test source atlib/linear/src/vector.zig:349in nearest public ownerlib.linear.src.vectorlib.linear.src.vector.test_vector_arithmetic_evaluates_each_lane_exactly[function] — test source atlib/linear/src/vector.zig:327in nearest public ownerlib.linear.src.vectorlib.linear.src.vector.test_vectors_share_the_layout_of_f32_arrays[function] — test source atlib/linear/src/vector.zig:385in nearest public ownerlib.linear.src.vector
Complete caller list for Vec3.normalized
21 direct callers.
fun.sdfii.src.audio.late.LateFieldService.buildCache[function] — private; no exact target atfun/sdfii/src/audio/late.zig:253in nearest public ownerfun.sdfii.src.audio.latefun.sdfii.src.audio.spatial.computePan[function] — private; no exact target atfun/sdfii/src/audio/spatial.zig:117in nearest public ownerfun.sdfii.src.audio.spatialfun.sdfii.src.audio.spatial.segmentMarch[function] — private; no exact target atfun/sdfii/src/audio/spatial.zig:62in nearest public ownerfun.sdfii.src.audio.spatialfun.sdfii.src.navigation.flow.generateFlowField[function] — private; no exact target atfun/sdfii/src/navigation/flow.zig:37in nearest public ownerfun.sdfii.src.navigation.flowfun.sdfii.src.navigation.harmonic.HarmonicNavigator.extractPath[method] — private; no exact target atfun/sdfii/src/navigation/harmonic.zig:378in nearest public ownerfun.sdfii.src.navigation.harmonicfun.sdfii.src.navigation.harmonic.HarmonicNavigator.navigateStep[method] — private; no exact target atfun/sdfii/src/navigation/harmonic.zig:356in nearest public ownerfun.sdfii.src.navigation.harmonicfun.sdfii.src.navigation.potential.PotentialFieldNavigator.navigateStep[method] — private; no exact target atfun/sdfii/src/navigation/potential.zig:209in nearest public ownerfun.sdfii.src.navigation.potentialfun.sdfii.src.navigation.potential.QueryPotentialNavigator.navigateStep[method] — private; no exact target atfun/sdfii/src/navigation/potential.zig:80in nearest public ownerfun.sdfii.src.navigation.potentialfun.sdfii.src.navigation.sight.lineOfSight[function] — private; no exact target atfun/sdfii/src/navigation/sight.zig:30in nearest public ownerfun.sdfii.src.navigation.sightfun.sdfii.src.sdf.gradient.chainGrad[function] — private; no exact target atfun/sdfii/src/sdf/gradient.zig:979in nearest public ownerfun.sdfii.src.sdf.gradientfun.sdfii.src.sdf.gradient.inverseOrientVec[function] — private; no exact target atfun/sdfii/src/sdf/gradient.zig:276in nearest public ownerfun.sdfii.src.sdf.gradientfun.sdfii.src.sdf.gradient.mirrorPoint[function] — private; no exact target atfun/sdfii/src/sdf/gradient.zig:287in nearest public ownerfun.sdfii.src.sdf.gradientfun.sdfii.src.sdf.gradient.orientPoint[function] — private; no exact target atfun/sdfii/src/sdf/gradient.zig:265in nearest public ownerfun.sdfii.src.sdf.gradientfun.sdfii.src.sdf.gradient.rotateAroundAxis[function] — private; no exact target atfun/sdfii/src/sdf/gradient.zig:250in nearest public ownerfun.sdfii.src.sdf.gradientfun.sdfii.src.sdf.vjp.accumulateSlotGradient[function] — private; no exact target atfun/sdfii/src/sdf/vjp.zig:775in nearest public ownerfun.sdfii.src.sdf.vjpfun.sdfii.src.sdf.vjp.conePartials[function] — private; no exact target atfun/sdfii/src/sdf/vjp.zig:1133in nearest public ownerfun.sdfii.src.sdf.vjpfun.sdfii.src.sdf.vjp.mirrorPoint[function] — private; no exact target atfun/sdfii/src/sdf/vjp.zig:1386in nearest public ownerfun.sdfii.src.sdf.vjpfun.sdfii.src.sdf.vjp.orientPoint[function] — private; no exact target atfun/sdfii/src/sdf/vjp.zig:1375in nearest public ownerfun.sdfii.src.sdf.vjpfun.sdfii.src.sdf.vjp.rotateAroundAxis[function] — private; no exact target atfun/sdfii/src/sdf/vjp.zig:1360in nearest public ownerfun.sdfii.src.sdf.vjplib.linear.src.test.arithmeticDigest[function] — private source atlib/linear/src/test.zig:38in nearest public ownerlib.linear.src.testlib.linear.src.vector.test_normalized_multiplies_by_the_reciprocal_length[function] — test source atlib/linear/src/vector.zig:359in nearest public ownerlib.linear.src.vector
Audit
| Definitions | 25 |
|---|---|
| Public names | 25 |
| Members | 3 |
| Version | 26.7.0 |
| Revision | daab053ee433 |