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 ?
Care to give us a clue to why so we know better what to suggest?
Fair enough, let me explain it further
I need to draw N rectangles side by side (their centers lying on a line or trajectory).
Works like this, user gives two points (left and right) then i need to draw a series of rectangles from the first point to the second with the rectangles centers lying on the line.
i figured for that i need to calculate the points that will lie on that line, hence the requirement for an algorithm that will give me the points that will lie on a line(x1,y1,x2,y2)
Secondly user will provide the color of the first rectangle and the last and i need to fill the rest of the rects with the gradient color, hence the requirement for a gradient algorithm
Here is a sample image (it uses sine wave i think instead of a line) Sample[^]
And lastly thanks for your valuable time
C++ where friends have access to your private members !
Well, this might be a place to get started. Bresenham's algorithm[^] certainly picks pixels to draw straight lines and some other curves. You might also check some of the 3D drawing class libraries, like VRML or the library that originated at SGI, as they often implement a process they call "extrude" where they sweep a shape through space that follows a curve, a cylinder is an example of extruding a circle along a straight line. I don't think they use pixels generally but you might get some ideas.
If you don't have the data, you're just another a**hole with an opinion.
Last Visit: 31-Dec-99 18:00 Last Update: 23-Oct-14 3:22