Point, arrow and rotation notes

A lot of moving around, placing and aiming can be done if you know simple vector math, rules for rotations/quaternions and can use some of the built-ins. Each problem is different -- this is hopefully enough theory that you can figure out most things, or understand someone else's vector/rotation code well enough to modify it.

This assumes you have a very basic knowledge of coding and know simple Unity3D navigation. Each section is only a few pages long.

 

Vectors and Rotations The whole thing as a pdf. 1/4th Meg. The links in the table of contents work.

 

  1. Basic terms pdf
  2. Point and offset math pdf
  3. Local/global axes pdf
  4. Direction & Magnitude pdf
  5. Rotation pdf
  6. Combining rotations pdf
  7. Moving points and rotations pdf
  8. More misc math pdf
  9. Local space trick pdf
  10. Examples pdf

 

Links to each chapter as htmls

Contents

0 Intro
 0.1 Review of basics
1 Vectors and offsets
 1.1 Points and Offsets
  1.1.1 More calculating offsets
 1.2 transform.position+offset
  1.2.1 Camera vector positioning
  1.2.2 Moving ourself
  1.2.3 Averaging points
 1.3 Math review
2 Local and Global axes
 2.1 Local axes
 2.2 Using your local axis in code
 2.3 Things that assume local coords
  2.3.1 Looking at the numbers
 2.4 Childing
  2.4.1 SetParent notes
 2.5 Errors
3 Direction & Length
 3.1 Magnitude/distance
  3.1.1 Direction
  3.1.2 Normalized direction
 3.2 Normalized direction + length
 3.3 Looking at the numbers
4 Rotations
 4.1 Quaternions
 4.2 Ways to make a rotation
  4.2.1 Y, local X, local Z rotations
  4.2.2 Rotate around an axis
  4.2.3 Look in a direction
  4.2.4 FromToRotation
  4.2.5 LookRotation’s extra roll
 4.3 Details and math
  4.3.1 Real Quaternion values
  4.3.2 dot-eulerAngles
  4.3.3 Multiple ways to write an angle
  4.3.4 How the Inspector handles rotation
  4.3.5 Gimbal lock, xyz problems
 4.4 Quaternion setting commands
5 Combining rotations
 5.1 Rotate an arrow
 5.2 Combining rotations
 5.3 Visualizing rotation combinations
6 Moving
 6.1 Moving a point
  6.1.1 MoveTowards
  6.1.2 Lerp
 6.2 Gradually rotating
  6.2.1 Spinning an arrow
  6.2.2 Moving a rotation
  6.2.3 Rotation lerp
 6.3 Time.deltaTime
7 Misc Math
  7.0.1 Finding angles
  7.0.2 Cross Product
  7.0.3 Normals
  7.0.4 Reflect
  7.0.5 Opposite of an angle
  7.0.6 Square magnitude
 7.1 Trig you should never use
  7.1.1 Radians
  7.1.2 atan2
  7.1.3 dot product
  7.1.4 Rotation matrixes
8 Using local space
 8.1 Local Space
 8.2 Local space tricks
  8.2.1 Converting rotations, offsets
 8.3 Built-in shortcuts
9 Misc examples
 9.1 Getting your y-spin
 9.2 Using a y-spin
 9.3 Align with ground
 9.4 Orbit camera
 9.5 Drawing a line between
 9.6 Consistant LookAt
 9.7 Connect two blocks

Comments. There's also a post in the Unity Teaching&Learning Forum.

Jan 10, 2017: in Rotation chapter; rewrite the Quaternion sections , fixes and small grammar changes elsewhere.

Nov, 2018: re-edit entire thing. Redo first rotation chapter; added connect-cubes to misc examples. Added entire-pdf-with-TOC and html chapters (htlatex can do that. Who knew? Well, everyone except me.)