OK. This is what I was trying to do.

Key code is as follows:

VectorRay = CP - OctoPer;
VectorRay = VectorRay/FractionalLength;

VectorPath = new Path(OctoPer, OctoPer + VectorRay);
VectorPath.strokeColor = "blue";

CenterPath = new Path(CP, CP - VectorRay);
CenterPath.strokeColor = 'red';

As should be fairly obvious, to utilize the VectorRay, all I needed to do was add the VectorRay to the relevant point. Either CP (the CenterPoint) or OctoPer(the point on the Perimeter of the Octogon).

I also added another CircleInput as a control box. If one clicks inside the circle, the FractionalLength variable is decreased by 1. It starts at 10. So at first the inside and outside segments are 1/10th the distance between the perimeter and center. At FractionalLenght = 2;, the two lines meet. They're different colors, as proof that they are different paths.

So, the VectorRay is the 'Normal' at the OctoGon's Perimeter (looking in). The line that is 90 degrees off from the tangent, which if I know my geometry, is the borderline of the OctoGOn.

Next up, getting that ball to bounce off the walls.


Previous      Brett Code Index    Next in Series

OctoWars Project
Copyright © 2013 Brett Paufler