Skip to content

Instantly share code, notes, and snippets.

@chrisbrasington
Last active July 25, 2016 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbrasington/070c69aed08f21d815db666327c8f0b9 to your computer and use it in GitHub Desktop.
Save chrisbrasington/070c69aed08f21d815db666327c8f0b9 to your computer and use it in GitHub Desktop.
Lengthen or Shorten a 3D Line by a length constant

Using current member structure, find deltas.

$$\Delta_x=\frac{x_2-x_1}{\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}}$$

$$\Delta_y=\frac{y_2-y_1}{\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}}$$

$$\Delta_z=\frac{z_2-z_1}{\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}}$$

c = new length constant

Point3d newEndPoint = new Point3D $$(x_2+c\Delta_x, y_2+c\Delta_y, z_2+c\Delta_z)$$;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment