Object placement

We need to place the benches and street-lights along the path. Although more generic placement mechanism may involve more elaborate placement strategies in the future.

In the previous post arrows were seen to be placed in the middle of the path. I have replaced arrows with simple ‘pick’ triangles, as it easier to compute direction with a triangle then more complex arrow object.

Where the object should be placed I add a¬†Isosceles triangle with the small base and the ‘vertex angle’ vertex moved further away from the centre of mass. The direction is the vector from the midpoint of the base to the ‘angle vertex’ vertex, which is obtained by selecting the vertex which does not belong to the base. Base is the shortest edge. I select the centre as the average of the angle vertex and the midpoint of the base (because of placement strategy, logically however centroid or centre of mass makes more sense).

Angle of rotation is can be obtained using arctan function but SketchUp already provides a Vector3d::angle_between member function.

Resulting park looks like this: