Join / Forgotten your password?
 
HomeFeaturesStoreForumsWikiWorkshopsJobsPortfolioGalleryEvents Members
 
> CGWiki Home       > Community Portal       > Current Events      > Recent Changes     > Random Page       > Join       > Support Forum       > Help     
 

Geometric Calculations (3dsmax)

Contents

Vectors

Normalization

A normalized vector has a length of exactly 1.0, this value can be multiplied to get exact lengths. ie. A normalized vector multiplied by 5.617 will give you a vector with the length 5.617.

Code:

normalize vec

Cross Product

Gives you the vector perpendicular to the two vectors supplied.

Code:

cross vec1 vec2

Dot Product

Gives you a relationship between two vectors.

Code:

dot vec1 vec2

Gives you the cosine of the angle between two normalized vectors.

Code:

dot (normalize vec1) (normalize vec2)

The result returned by a dot product passed, when acos'd will return the angle in degrees between the two vectors.

Code:

acos (dot (normalize vec1) (normalize vec2))

Line

A line can be defined by:

  • 2 points
  • a point of origin and an offset vector
  • a point of origin, a normalized vector and a scalar length

Mid-Point

The exact center between two points.

Code:

fn midPoint pt1 pt1 = ((pt1+pt2)/2.0)

Linear Interpolation (LERP)

Code:

fn lerp pt1 pt2 alpha = (pt1+((pt2-pt1)*alpha))

Plane

A plane can be defined by

  • 3 non-colinear points
  • a point and 2 vectors
  • a point and a normalized vector (the normal vector)

Distance Between a Point and a Plane

Plane (vector/point)

  • vec = plane vector
  • ppt = a point on the plane
  • pt = point you want to test

Code:

fn PointToPlaneDist vec ppt pt = 
    (vec.x*pt.x+vec.y*pt.y+vec.z*pt.z) - (vec.x*ppt.x+vec.y*ppt.y+vec.z*ppt.z)

Acknowledgements

Article inspired by the Geometrical Calculations post on CGTalk