luceda ipkiss教程 43:画渐变圆弧型波导

2023-12-09 02:01

本文主要是介绍luceda ipkiss教程 43:画渐变圆弧型波导,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

案例分享:
在这里插入图片描述

from si_fab import all as pdk
import ipkiss3.all as i3
from ipcore.properties.restrictions import RestrictTuple
from ipkiss.geometry.shapes.modifiers import __ShapePathBase__
import numpy as np
from math import atan2class ShapePathTaperExtended(__ShapePathBase__):""" Tapered path with extended ends based on a shape. """extension = i3.Tuple2Property(restriction=RestrictTuple((float)),doc="extension of the path shape at start and end: (start, end)")end_path_width = i3.PositiveNumberProperty(doc="end width of path")start_path_width = i3.PositiveNumberProperty(doc="start width of path")def _default_end_path_width(self):return self.path_widthdef _default_path_width(self):return self.start_path_widthdef _default_extension(self):return 0., 0.def __init__(self, original_shape, start_path_width, end_path_width, **kwargs):super(ShapePathTaperExtended, self).__init__(original_shape=original_shape,start_path_width=start_path_width,end_path_width=end_path_width,**kwargs)def define_points(self, pts):# TODO: include start_face_angle and end_face_angle in the calculationsstart_ext, end_ext = self.extensionwest_coords = i3.Shape()east_coords = i3.Shape()orig_shp = i3.Shape(self.__get_original_shape_without_straight_angles__())start_angle, end_angle = orig_shp.get_face_angles()if len(orig_shp) == 0 or np.isclose(orig_shp.length(), 0.):return pts# beginorig_shp[0] = orig_shp[0].move_polar(-start_ext, start_angle)# endorig_shp[-1] = orig_shp[-1].move_polar(end_ext, end_angle)dist = [i3.distance(orig_shp[_], orig_shp[_ + 1]) for _ in range(len(orig_shp) - 1)]widths = [(self.end_path_width - self.path_width) * np.sum(dist[:_]) / np.sum(dist) + self.path_width for _ inrange(len(orig_shp))]coords = orig_shp.pointsn_points = len(coords)start_angle, end_angle = orig_shp.get_face_angles()# middlefor i in range(n_points):x = coords[i][0]y = coords[i][1]if i == 0:angle1 = i3.DEG2RAD * start_angleangle2 = atan2(coords[i + 1][1] - y, coords[i + 1][0] - x)elif i == n_points - 1:angle1 = atan2(y - coords[i - 1][1], x - coords[i - 1][0])angle2 = i3.DEG2RAD * end_angleelse:angle1 = atan2(y - coords[i - 1][1], x - coords[i - 1][0])angle2 = atan2(coords[i + 1][1] - y, coords[i + 1][0] - x)angle = angle1 + 0.5 * (angle2 - angle1 + np.pi) % (np.pi) - 0.5 * np.piturn = (angle2 - angle1) % (2 * np.pi)ca = np.cos(angle)sa = np.sin(angle)if turn == np.pi and i not in [0, n_points - 1]:i3.LOG.error("Path to Boundary conversion is not possible with paths that turn 180 degree at a node")raise SystemExitw = 0.5 * widths[i] / np.abs(np.cos(0.5 * turn))c_west = (x - w * sa, y + w * ca)c_east = (x + w * sa, y - w * ca)west_coords.append(c_west)east_coords.append(c_east)east_coords.reverse()pts.extend(west_coords)pts.extend(east_coords)pts.append(west_coords[0])return ptsclass gradient_arc(i3.PCell):class Layout(i3.LayoutView):radius = i3.PositiveNumberProperty(doc="Radius of the central bends", default=100.0)def _generate_elements(self, elems):shape_wg1 = [(0.0, 0.0),(self.radius, 0),(self.radius, self.radius),(self.radius, 2 * self.radius),(0, 2 * self.radius),]shape_wg1_path = i3.ShapeRound(original_shape=shape_wg1, radius=self.radius)elems += i3.Boundary(layer=i3.TECH.PPLAYER.SI,shape=ShapePathTaperExtended(original_shape=shape_wg1_path,start_path_width=10,end_path_width=1,))return elemsif __name__ == '__main__':gradient_arc().Layout().visualize()

这篇关于luceda ipkiss教程 43:画渐变圆弧型波导的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/472089

相关文章

Linux卸载自带jdk并安装新jdk版本的图文教程

《Linux卸载自带jdk并安装新jdk版本的图文教程》在Linux系统中,有时需要卸载预装的OpenJDK并安装特定版本的JDK,例如JDK1.8,所以本文给大家详细介绍了Linux卸载自带jdk并... 目录Ⅰ、卸载自带jdkⅡ、安装新版jdkⅠ、卸载自带jdk1、输入命令查看旧jdkrpm -qa

Java使用Curator进行ZooKeeper操作的详细教程

《Java使用Curator进行ZooKeeper操作的详细教程》ApacheCurator是一个基于ZooKeeper的Java客户端库,它极大地简化了使用ZooKeeper的开发工作,在分布式系统... 目录1、简述2、核心功能2.1 CuratorFramework2.2 Recipes3、示例实践3

springboot简单集成Security配置的教程

《springboot简单集成Security配置的教程》:本文主要介绍springboot简单集成Security配置的教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录集成Security安全框架引入依赖编写配置类WebSecurityConfig(自定义资源权限规则

MySQL Workbench 安装教程(保姆级)

《MySQLWorkbench安装教程(保姆级)》MySQLWorkbench是一款强大的数据库设计和管理工具,本文主要介绍了MySQLWorkbench安装教程,文中通过图文介绍的非常详细,对大... 目录前言:详细步骤:一、检查安装的数据库版本二、在官网下载对应的mysql Workbench版本,要是

通过Docker Compose部署MySQL的详细教程

《通过DockerCompose部署MySQL的详细教程》DockerCompose作为Docker官方的容器编排工具,为MySQL数据库部署带来了显著优势,下面小编就来为大家详细介绍一... 目录一、docker Compose 部署 mysql 的优势二、环境准备与基础配置2.1 项目目录结构2.2 基

Linux安装MySQL的教程

《Linux安装MySQL的教程》:本文主要介绍Linux安装MySQL的教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux安装mysql1.Mysql官网2.我的存放路径3.解压mysql文件到当前目录4.重命名一下5.创建mysql用户组和用户并修

最新Spring Security实战教程之Spring Security安全框架指南

《最新SpringSecurity实战教程之SpringSecurity安全框架指南》SpringSecurity是Spring生态系统中的核心组件,提供认证、授权和防护机制,以保护应用免受各种安... 目录前言什么是Spring Security?同类框架对比Spring Security典型应用场景传统

最新Spring Security实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)

《最新SpringSecurity实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)》本章节介绍了如何通过SpringSecurity实现从配置自定义登录页面、表单登录处理逻辑的配置,并简单模拟... 目录前言改造准备开始登录页改造自定义用户名密码登陆成功失败跳转问题自定义登出前后端分离适配方案结语前言

Centos环境下Tomcat虚拟主机配置详细教程

《Centos环境下Tomcat虚拟主机配置详细教程》这篇文章主要讲的是在CentOS系统上,如何一步步配置Tomcat的虚拟主机,内容很简单,从目录准备到配置文件修改,再到重启和测试,手把手带你搞定... 目录1. 准备虚拟主机的目录和内容创建目录添加测试文件2. 修改 Tomcat 的 server.X

Python中的输入输出与注释教程

《Python中的输入输出与注释教程》:本文主要介绍Python中的输入输出与注释教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、print 输出功能1. 基础用法2. 多参数输出3. 格式化输出4. 换行控制二、input 输入功能1. 基础用法2. 类