DarwinNE / FidoCadJ

FidoCadJ is a free user-friendly vector graphic editor for MacOSX, Linux, Windows and Android with a library of electronic symbols.
http://darwinne.github.io/FidoCadJ/
GNU General Public License v3.0
116 stars 43 forks source link

Rotating objects #222

Closed JoopN closed 1 year ago

JoopN commented 2 years ago

When you drag an object from the lib to your drawing area you can rotate it with 90 degrees increments. Is it possible to enhance this feature within the standard to more positions like 45 degrees steps or like with text you have to fill in a number between 0 and 360. I had several lib items which had to be in 45 degree angle and it turned out that this is not easy to do.

DarwinNE commented 2 years ago

The problem for this is that the coordinate system is not precise enough to rotate objects by an arbitrary angle. I'd like to increase the precision of the coordinates, but that would be a huge work that I do not have the courage to start. A big deal would be to maintain backward compatibility!

JoopN commented 2 years ago

Okay, by an arbitrary angle is for me everything. Would it be easier if you took angles by 15 degrees. So 0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180 and so on up to 360? So the rotating angle is the same 15 degrees, and you can multiply that. Backward compatibility is already build in with in the settings "Strict FidoCAD compatibility", so I don't see any problems for moving on within the philosophy of FidoCad.

DarwinNE commented 2 years ago

Hello, the problem remains difficult to solve as the coordinate system is based on integer numbers. Rotation involves calculation of sines and cosines and they yield irrational numbers for many common angles. If the coordinates are rounded off, the shape of the components will be deformed. This will be visible for small components such as those in the library for schematic. Basically a rotation by an arbitrary angle would become possible only if the whole coordinate system is based on floating point (or fixed point) numbers. This requires to take some decisions so that the output files will remain compact in most situation where the additional precision is not required.

As a partial workaround, it is possible to draw manually and define symbols that are rotated and use those. For instance the EY library contains a diode drawn with an axis oriented 45° with respect to the horizontal:

[FIDOCAD]
MC 45 25 0 0 ey_libraries.didid1