Ive been strggling tring to implement snapPerpendicular, and the chief made me realize that there must be some way of passing data of the entity that is beeing created, and that goes far beyond messing with the snaping system. So i propose a method like ->inCreation in the main container, that goes deep into the main engine, so i think is up to the main guys to discuss this.
I also believe that this will benefit future features. |
Hi Fernando,
It's impractical to first generate the entities followed by checking perpendicular conditions. However, it's possible to follow the rs_creation route. The rs_snapper class holds a boolean flag of "perpendicular enabled". For each new entity drawing action, in the last step, say, like the second point of drawing a line, rs_creation is called, if snap perpendicular is enabled, if not enabled, the usual routine. within rs_creation, it's needed to implement new methods to create an entity based on info passed from action classes. For example, in the draw line case, it receives the first point from the drawLine action. rs_creation can search through entityContainer and find all perpendicular points, choose the one closest to mouse pointer which is also passed from action classes. Basically, for each drawing method, there should be one rs_creation. You may first play with the simplest case of "Draw line 2 points". Regards, Dongxu On Mon, Mar 5, 2012 at 7:58 PM, Fernando [via LibreCAD] <[hidden email]> wrote: Ive been strggling tring to implement snapPerpendicular, and the chief made me realize that there must be some way of passing data of the entity that is beeing created, and that goes far beyond messing with the snaping system. So i propose a method like ->inCreation in the main container, that goes deep into the main engine, so i think is up to the main guys to discuss this. -- Dongxu Li, Ph.D. www.librecad.org |
Dongxu, I dont get it: Why go through all possible perpendiclar points? Shouldnt snap just check nearest entities from the cursor?
2012/3/6 dxli [via LibreCAD] <[hidden email]> Hi Fernando, -- Fernando da Motta Hildebrand |
Hi Fernando,
If we are doing line by 2 points, you only have to check for the nearest entity. In general, it may not be possible to create a new entity perpendicular to the nearest entity, with given conditions. This is quite general, but I can give an example here. LC supports drawing ellipses by specifying: center followed by 3 points on ellipse. In this particular case, we expect "Snap perpendicular" to work in providing candiates for the last point, i.e., after being given ellipse center, and 2 points on ellipse. With given conditions, it's generally impossible to require the ellipse to be perpendicular to an arbitrary line pass the ellipse center. Without losing of generality, the center is (0,0) here, the ellipse equation is quadratic form: a x^2 + 2 b x y + c x^2 = 1 an ellipse perpendicular to a line passing (0,0) means the line is along the eigenvector of the quadratic form, therefore determined by the first two given points. Give it some numbers here: center (0,0), first point (1,0), second point (0,1), the eigen vectors are (1, 1), (1, -1), so, only possible if the line passing (0,0) is y=x, y= -x (plus the degenerate case b = 0, then, either y=0, or x=0). Other examples can be drawing a tangential line of a circle/ellipse, with the tangential line perpendicular to another entity. Regards, Dongxu On Tue, Mar 6, 2012 at 7:47 PM, fernandohildebrand [via LibreCAD] <[hidden email]> wrote: Dongxu, I dont get it: Why go through all possible perpendiclar points? Shouldnt snap just check nearest entities from the cursor? -- Dongxu Li, Ph.D. www.librecad.org |
It may be a nonsense but...
A snapPerpendicular is a point from "relative zero" to entity in mouse. line by 2 points case with a snapPerpendicular activated click the first point, the relative zero are moved to the clicked point, click the second point, RS_Snapper::snapPoint is called snapPoint gets the "relative zero" coordinate and calculate the perpendicular point in the entity over the mouse |
Hi Rallaz, sounds like I misunderstood this feature. so snap perpendicular is the projected point of relative zero on the nearest entity. if so, it's straight forward to implement it. i still want to see some examples first. thanks, dongxu On Mar 7, 2012 11:23 AM, "Rallaz [via LibreCAD]" <[hidden email]> wrote:
It may be a nonsense but... |
Now i got confused too.... I dont think thats the way it works...
2012/3/7 dxli [via LibreCAD] <[hidden email]>
-- Fernando da Motta Hildebrand |
Free forum by Nabble | Edit this page |