This paper describes a technique to obtain an optimal collision-free path for robotic manipulators and/or automated guided vehicles (AGVs) in 2D and 3D by synthesizing a B-spline curve. The problem is formulated as a combinatorial optimization problem and solved by using simulated annealing. A two-link planar manipulator is included to show that the B-spline curve can also be synthesized by adding kinematic characteristics of the robot. To demonstrate the robustness of the technique, several examples in 2D and 3D are presented. A direction for further research is discussed.