Re: gEDA-user: pcb GL can't render stretched arcs

2011-07-15 Thread Karl Hammar
Andrew Poelstra:
 On Thu, Jul 14, 2011 at 08:29:53PM +0200, Karl Hammar wrote:
...
  Why not just give a warning if width and height is not equal, saying
  that we don't really support ellipses for the moment, and be done with
  it.
 I could, I suppose, but as you mentioned in another post, there
 are muddled physical units. As that is what I am trying to fix,
 I need to make changes anyway.

Ok.

 It would be nice if we could at least support the featureset of
 our file format, while I'm at it.

I found in [1]:

Given an ellipse:

 x^2 / a^2 + y^2 / b^2 = 1

 where
  a = greater semiaxis
  b = lesser  semiaxis
  a = b  0
  e = sqrt( a^2 + b^2 ) = linear excentricity = focalpoint semidistance
  epsilon = e / a = numerical excentricity


The equation of the normal to the ellipse:

 y - y1 = mn * (x - x1),   where mn = (a*a * y1) / (b*b * x1)

 the point on the ellipse = (x1, y1)
 point on normal = (x, y)

The length of the normal (to where it crosses the x-axis):

 n = b * sqrt(a*a*a*a - e*e * x1*x1) / (a*a)

The length of the subnormal (as above but along the x-axis):

 sn = abs( b*b * x1 / (a*a) )  

Hope that it helps.
We're here if you need more help.

Regards,
/Karl Hammar

[1]
 Mathematische formeln
 Dipl.-Ing. Hans-Jochen Bartsch
 Veb Fachbuschverlag Leipzig 1974

---
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57




___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: pcb GL can't render stretched arcs

2011-07-15 Thread Karl Hammar
Ethan Swint:
 On 07/14/2011 11:23 PM, Andrew Poelstra wrote:
...
  To do either one analytically looks like a 4th order
  equation must be solved. So I am looking for cheap
  iterative solutions, or approximations, instead.

 If the point is within the arc's bounding box, transform the point's 
 global coordinates into the arc's local (x: major axis, y: minor axis) 
 coordinates.

Ack.

  Then the distance calculation is a no-brainer.

Could you then show us the formula please ?

Regards,
/Karl Hammar

---
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57




___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: pcb GL can't render stretched arcs

2011-07-15 Thread Andrew Poelstra

I am using the polar form of the ellipse given at:

http://en.wikipedia.org/wiki/Ellipse#Polar_form_relative_to_center

with theta the angle of the point we are checking. (Those cos
and sin calculations are easy, just delta-x/len and delta-y/len.)
With that I can calculate the distance from the point to an
ellipse.

Restricting this to an ellipse /segment/ is tricky, since as DJ
pointed out, these are not real elliptical arcs, but stretched
arcs, so the limiting angles do not correspond directly to actual
angles.

Adding explicit checks for distance from endpoints would give
us an almost-correct solution.

There are still pathologies I can think of with arcs whose
thickness (or thickness + search radius) is greater than the
minor axis, though..

-- 
Andrew Poelstra
Email: asp11 at sfu.ca OR apoelstra at wpsoftware.net
Web:   http://www.wpsoftware.net/andrew/



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


gEDA-user: generic symbols en custom pin numbers

2011-07-15 Thread Hans Schulz
As sort of an extension to heterogeneous symbols I wonder how I can make
generic symbols, consisting of a set of subsymbols, e.g. a relay coil
and several types of contact arrangements like SPST and SPDT, all as
separate, little symbols. In my design I would then select the
appropriate subparts and assemble a particular arrangement, assign the
same refdes to them (probably suffixed by a, b, c or similar in
lower case). So far this is simply possible with gschem AFAIK.
BUT: relays (to stick to the example) come in (very) many different
physical shapes and layouts, each with its own, vendor dependent pin
numbering scheme. Therefore, it would be nice to have the possibility to
define the pin numbers in the instantiation at the schematic level
rather than the fixed pin numbers as defined in the symbol (class
level). The slot mechanism is not intented nor useable for this.
I have not found any way to promote the pinnumbers to the instantiation
or other ways to achieve this.
Suggestions more than welcome!
thank you,
hans



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: pcb GL can't render stretched arcs

2011-07-15 Thread Karl Hammar
Andrew Poelstra:
 I am using the polar form of the ellipse given at:
 
 http://en.wikipedia.org/wiki/Ellipse#Polar_form_relative_to_center
 
 with theta the angle of the point we are checking. (Those cos
 and sin calculations are easy, just delta-x/len and delta-y/len.)
 With that I can calculate the distance from the point to an
 ellipse.

The shortest line from (x,y) to the ellipse goes through the normal to
the ellipses perimeter.

The normal does not generally go through the middlepoint of the ellipse.
It crosses the line between the center and the nearest focal point.

What you get with the above polar calculation is a little bigger value
than the true distance, but it could serve as a first aproximation.
You could take the minimum of the polar form through the center and
through the focus, to get a better value.

How accurate an value do we need, would minimum of ±5% and ±0.1mm
be ok ?

 Restricting this to an ellipse /segment/ is tricky, since as DJ
 pointed out, these are not real elliptical arcs, but stretched
 arcs, so the limiting angles do not correspond directly to actual
 angles.
...

Isn't that a bug to be fixed instead?

Regards,
/Karl Hammar

---
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57




___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: generic symbols en custom pin numbers

2011-07-15 Thread Karl Hammar
Hans Schultz:
 As sort of an extension to heterogeneous symbols I wonder how I can make
 generic symbols, consisting of a set of subsymbols, e.g. a relay coil
 and several types of contact arrangements like SPST and SPDT, all as
 separate, little symbols. In my design I would then select the
 appropriate subparts and assemble a particular arrangement, assign the
 same refdes to them (probably suffixed by a, b, c or similar in
 lower case). So far this is simply possible with gschem AFAIK.
 BUT: relays (to stick to the example) come in (very) many different
 physical shapes and layouts, each with its own, vendor dependent pin
 numbering scheme. Therefore, it would be nice to have the possibility to
 define the pin numbers in the instantiation at the schematic level
 rather than the fixed pin numbers as defined in the symbol (class
 level). The slot mechanism is not intented nor useable for this.
 I have not found any way to promote the pinnumbers to the instantiation
 or other ways to achieve this.

I think you currently are restricted to create a seperate footprint file
for each of your alternatives.

Though it would be nice to be able to pass parameters to the footprint
and more or less treat is like a subroutine.

Regards,
/Karl Hammar

---
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57




___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: pcb GL can't render stretched arcs

2011-07-15 Thread Andrew Poelstra
On Fri, Jul 15, 2011 at 09:45:42PM +0200, Karl Hammar wrote:
 Andrew Poelstra:
  I am using the polar form of the ellipse given at:
  
  http://en.wikipedia.org/wiki/Ellipse#Polar_form_relative_to_center
  
  with theta the angle of the point we are checking. (Those cos
  and sin calculations are easy, just delta-x/len and delta-y/len.)
  With that I can calculate the distance from the point to an
  ellipse.
 
 The shortest line from (x,y) to the ellipse goes through the normal to
 the ellipses perimeter.


Ohh... of course. Darn.
 
 The normal does not generally go through the middlepoint of the ellipse.
 It crosses the line between the center and the nearest focal point.
 
 What you get with the above polar calculation is a little bigger value
 than the true distance, but it could serve as a first aproximation.
 You could take the minimum of the polar form through the center and
 through the focus, to get a better value.
 
 How accurate an value do we need, would minimum of ±5% and ±0.1mm
 be ok ?
 

I suspect that determining an error bound on my method would be
just as difficult (mathematically) as finding a different method.

There is a fairly informative discussion of this problem on SO:
http://stackoverflow.com/questions/2945337/how-to-detect-if-an-ellipse-intersectscollides-with-a-circle

The correct methods given there generally require root-solvers,
and I don't think we have one right now. We could throw one
together or introduce a dependency on, say, the GNU Scientific
Library.

Since we rarely care about the exact distance, only is it between
0 and Radius it is probable that we could use a bisection method
with very few iterations to get an answer.

  Restricting this to an ellipse /segment/ is tricky, since as DJ
  pointed out, these are not real elliptical arcs, but stretched
  arcs, so the limiting angles do not correspond directly to actual
  angles.
 ...
 
 Isn't that a bug to be fixed instead?


It's a design flaw, but fixing it would break existing designs.

-- 
Andrew Poelstra
Email: asp11 at sfu.ca OR apoelstra at wpsoftware.net
Web:   http://www.wpsoftware.net/andrew/



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: pcb GL can't render stretched arcs

2011-07-15 Thread Igor Lopez
2011/7/16 Andrew Poelstra as...@sfu.ca:
 There is a fairly informative discussion of this problem on SO:
 http://stackoverflow.com/questions/2945337/how-to-detect-if-an-ellipse-intersectscollides-with-a-circle

I had a look and found one algebraic solution close to the one I have proposed.

 The correct methods given there generally require root-solvers,

Why is the algebraic solution not correct?

 Since we rarely care about the exact distance, only is it between
 0 and Radius it is probable that we could use a bisection method
 with very few iterations to get an answer.

I am convinced we do not need any iterations or equation solvers.
We just need to check with the transformed point coordinates
in the equations for the two arcs where one is the inner arc and
the other is the outer arc where the point radius has been subtrcacted
respectively added to the arc lenghts(width, height).
If the point intersects the equation for the inner arc is = 0 and
the equation for the outer arc is = 0 and since it is not a complete
ellipse one need to check that the angle between point and
arc centerpoint is within the arcs limiting angles which is not
to difficult if the limiting angles are known.

  Restricting this to an ellipse /segment/ is tricky, since as DJ
  pointed out, these are not real elliptical arcs, but stretched
  arcs, so the limiting angles do not correspond directly to actual
  angles.

This is the true problem, if the limiting angles are not know then
the problem is unsolvable but I assume there is a way of finding
what the real limiting angles are. I have not looked into how they
become stretched but there must be a systematic way the stretch
transforms the arc.


 Isn't that a bug to be fixed instead?


 It's a design flaw, but fixing it would break existing designs.

Well, one could still keep the (wrong when stretched) limiting
angles and add new paramters to the struct for real angles.
Now I also assume from looking at DJ's stretched arc that the
axis length along the not stretched direction must also be
recalculated.
I'll be back.


 --
 Andrew Poelstra
 Email: asp11 at sfu.ca OR apoelstra at wpsoftware.net
 Web:   http://www.wpsoftware.net/andrew/



 ___
 geda-user mailing list
 geda-user@moria.seul.org
 http://www.seul.org/cgi-bin/mailman/listinfo/geda-user



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user