Draw a cruved line?

Okay so Imma have a weapon in my game, that when fire will draw a line(simular to that of the physgun in gmod) and I was it to be curved, I Will show you a drawing bellow.

alt text

Now I need to draw a beam like that with a curve like that, I can do the maths but I dont know how I would go about acctually drawing a line to an object in 3d space, And then also making it curve. Thanks

this is paste of a previous answer gave:

You should try Catmull Rom algorithm:

http://www.mvps.org/directx/articles/catmull/

Equation goes as such in 2D:

 public static Vector2 InterpolateFromCatmullRomSpline(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t) {
	return 0.5f * ((2f * p2) + (-p1 + p3) * t + (2f * p1 - 5f * p2 + 4f * p3 - p4) * Mathf.Pow(t, 2f) + (-p1 + 3f * p2 - 3f * p3 + p4) * Mathf.Pow(t, 3f));
 }
 public static Vector3 InterpolateFromCatmullRomSpline(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, float t) {
	return 0.5f*( (2f*p2) + (-p1 + p3)*t + (2f*p1 - 5f*p2 + 4f*p3 - p4)*Mathf.Pow(t, 2f) + (-p1 + 3f*p2 - 3f*p3 + p4)*Mathf.Pow(t, 3f));
 }

You define discrete points on your curve and it will define the movement naturally. The last parameter t is how accurate you want the curve. The higher t, the more expensive your curve but the more precise as well.

Since the equation takes A,B,C and D but it returns the path between B and C (look at explanation in the link) the first and last computation will get Vector2.zero for the first parameter (entry point) and for the last parameter (exit point).

For the rest you just pass all values in a array and use a for loop.