# Tag Info

15

Generating Normals As Maximus Minimus notes in the comments, when we have a mesh without normal vectors (say just raw vertex positions from a procedural generator or 3D scanned point cloud), we can determine a normal vector for each triangle of the mesh using the cross product of two of the triangle's edges, ensuring the vector is perpendicular to the ...

3

A 4x4 homogeneous matrix can represent any affine transformation. That is, any combination of: Translation by any offset Rotation around any axis by any angle Scale along multiple arbitrary axes by any scale factor Shearing in any plane by any factor Including any arbitrary composition of the above, in any order - like rotating then scaling then rotating ...

3

Many.. many things: calculating normals for light/physics calculation using for calc distances (point/plane) checking orientation of (2D)-Polys (are they left or right wound?) calculating 2D-area of general polygons (ok, it is using a "shrinked" 2d-cross product)

2

Coordinate systems For CG (computer graphics) we use hierarchical coordinate systems. Coordinate systems often called a space (World, Screen/View, Local space) define an origin, scale and rotation in 2D, 3D, ... nD. Hierarchy connects the coordinate spaces (generally via transformation matrices) An object in its local space is transformed to world space (...

1

Here's a simple way to model an object towed from one end by a rope that can coil up shorter but never stretch longer than a given length. public class SledFollow : MonoBehaviour { [SerializeField] [Tooltip("Object that pulls the sled.")] Transform _leader; [SerializeField] [Tooltip("Position on the sled's local z+ axis ...

1

Velocities in Unity are almost always in world space coordinates. So unless you see something that specifically promises you a local space velocity, world space should be your default assumption. This is the easiest coordinate system to use for handling interactions with objects outside this single entity (like the navmesh, or collisions). On the occasion ...

1

The names "world matrix" and "model matrix" are just terminology, and are not 100% standardised, so depending which source you read you may see them being used to refer to a number of different things. Generally speaking, your 3D scene will consist of the following: Objects that move around in the scene. Static parts of the scene that ...

1

As @DMGregory answered in the comment it can be done this way: const a = new Vector3(xa, ya, za); const b = new Vector3(xb, yb, zb); const c = b.clone().sub(a); const far = c.length(); const raycaster = new Raycaster(b, c.normalize(), 0, far); const intersections = raycaster.intersectObjects(scene); `

1

Assuming you have the Transform for your target object, and the Transform of the body the head is attached to, you can compute whether it's on the left or right side of the body by looking at the sign of the dot product: Vector3 toTarget = target.position - body.position; float dot = Vector3.Dot(toTarget, body.right); if (Mathf.Approximately(dot, 0f)) { ...

1

You have a double-delta there. You have a delta on the position (you change the position relative to the current position, based on the angle), and you also have a delta on the angle (you change the angle relative to the previous angle). That is equivalent to having the position change every frame, but also having the velocity change every frame. What you ...

1

Given an initial vector $\vec b$ of arbitrary length, we can calculate two scale factors that will bring it to the same horizontal or vertical offset as our reference vector $\vec a$: $$s_x = \frac {a_x} {b_x}\\ s_y = \frac {a_y} {b_y}$$ Choose $s_x$ if you want both vectors to arrive at the same vertical line (same horizontal offset), or $s_y$ if ...

1

Fundamentally, you have a right-angle triangle Your vector a is (conveniently) the adjacent side You want to know the length of the hypotenuse which is coincident with b. θ is the angle between your two vectors which we can get by calculating their dot product. So I can't see any simpler option than magnitude(a)/cos(dot(a, b)) Note that in your question, ...

1

PlaneY = Vector3.up & PlaneX = plane.transform.forward One of these things is not like the other. You're using a global axis vector for one, and the plane's axis vector for the other. Try this instead: PlaneY = -plane.transform.right; PlaneX = plane.transform.forward; Or: var localPosition = plane.transform.InverseTransformPoint(ballPosition); ...

Only top voted, non community-wiki answers of a minimum length are eligible