The only things you need to remember are:
> Math.Sin and Math.Cos take the angle argument in radians not degrees.
> Sin and Cos return double precision numbers: which may round to 0 or 1 if you are using integer positions and therefore the tank will not move as you want.
i have set of 2D points and i want to offset with a given distance (like offset command in AutoCAD)
i do not know how to deal with corners. i have searched on Internet, there are advanced methods like straight skeletons etc. but my polyline is not self crossing and no holes in it.
At the end, it is a translation however it must be implemented with respect to the normals, as far as i read through if it is a parametric curve then it is rather complicated. If you like to see how much it can further get complicated, you can have a look at the link below.
There is no simple solution to this problem, the best known general solution, is to create capsules between consecutive point pairs of your polyline where the capsule width is the offset, then union the capsule outlines. The capsule may be centered around the edge or it may be biased towards one side of the edge it is really up to the end requirement. For the union operation use something like Alan Murta's Generic Polygon Clipper library.
If you know your polyline is enclosed and represents a convex polygon, then simply calculate the centroid, then offset each edge by the product of the desired offset amount and the vector composed of the mid-point of the edge at hand minus the centroid.
A simple example can be found here:
im trying to convert Quaternion to Euler but i dont have appropriate code, i searched on lots of sites but their converting code do not match with converting back, mean, if i convert from Quaternion to Euler then i convert back the result value to Quaternion, i got different output, here is my code
Doing a quick scan they look like the common formulas out there.
Be aware, the formulas depend on the order you apply the rotations e.g. XYZ, ZXY, YZX, ...
ToEuler may be derived for one order and ToEulerA another.
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
unfortunately i got code from that site, that site converter have some incorrect conversion, eg. at the end of page you will find a java converter, write real = 1, i = 1, and output will be 116.56505117707799, now put this 116.56505117707799 in Euler to Quaternion converter on another page and now result is completely different, why ?