ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2019/03/08/14:12:15

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6
X-Exmh-Isig-CompType: repl
X-Exmh-Isig-Folder: inbox
From: karl AT aspodata DOT se
To: geda-user AT delorie DOT com
Subject: Re: [geda-user] Re: Is FreeRotateBuffer implemented in gschem?
In-reply-to: <alpine.DEB.2.20.1903081919370.4145@nimbus>
References: <201903081710 DOT x28HAAUG016981 AT delorie DOT com> <alpine DOT DEB DOT 2 DOT 20 DOT 1903081919370 DOT 4145 AT nimbus>
Comments: In-reply-to Roland Lutz <rlutz AT hedmen DOT org>
message dated "Fri, 08 Mar 2019 19:19:51 +0100."
Mime-Version: 1.0
Message-Id: <20190308191019.787D085E7F7D@turkos.aspodata.se>
Date: Fri, 8 Mar 2019 20:10:19 +0100 (CET)
X-Virus-Scanned: ClamAV using ClamSMTP
Reply-To: geda-user AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-user AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Roland Lutz:
> On Fri, 8 Mar 2019, (mail AT crcomp DOT net) [via geda-user AT delorie DOT com] wrote:
...
> > My goal to rotate a zenier diode by 45?? in gschem seems unobtainable 
> > at present.
...
> def rotate(rev, angle):
>      for ob in rev.all_objects():
>          if isinstance(ob.data(), xorn.storage.Arc):
>              ob.x, ob.y = (math.cos(angle) * ob.x - math.sin(angle) * ob.y,
...

You calc cos() and sin() mult. times, perhaps caching the values would 
be beneficial, as you do for angle:

>          angle = float(sys.argv[2]) * math.pi / 180.
...

In [1], I snap to gridpoints with (nearest grid point):

sub rnd( $ ) {
    my $dbl = shift;
    int( $dbl + 0.5 );
}

sub snap( $ ) {
    my $dbl = shift;
    rnd( $dbl/$grid ) * $grid;
}
...
    $x2 += $pin_length * $cos;
    $y2 += $pin_length * $sin;
    $x2 = snap($x2);
    $y2 = snap($y2);
...

It is well tested (for positive koordinates), see e.g. [2].
The only question is what grid size you want to use.

Also you might want to keep text, labels and such horizontal or vertical.
For complex symbols, it might be better to use a symbol generator that 
handles thoose details for you.

Regards,
/Karl Hammar

[1] http://aspodata.se/git/openhw/pdftosym/pintosym.pl
[2] http://aspodata.se/git/openhw/pdftosym/examples.pintosym/stm32f100lm.circle.LQFP100.sym


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019