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

相关文章

Maven的使用和配置国内源的保姆级教程

《Maven的使用和配置国内源的保姆级教程》Maven是⼀个项目管理工具,基于POM(ProjectObjectModel,项目对象模型)的概念,Maven可以通过一小段描述信息来管理项目的构建,报告... 目录1. 什么是Maven?2.创建⼀个Maven项目3.Maven 核心功能4.使用Maven H

IDEA自动生成注释模板的配置教程

《IDEA自动生成注释模板的配置教程》本文介绍了如何在IntelliJIDEA中配置类和方法的注释模板,包括自动生成项目名称、包名、日期和时间等内容,以及如何定制参数和返回值的注释格式,需要的朋友可以... 目录项目场景配置方法类注释模板定义类开头的注释步骤类注释效果方法注释模板定义方法开头的注释步骤方法注

Python虚拟环境终极(含PyCharm的使用教程)

《Python虚拟环境终极(含PyCharm的使用教程)》:本文主要介绍Python虚拟环境终极(含PyCharm的使用教程),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录一、为什么需要虚拟环境?二、虚拟环境创建方式对比三、命令行创建虚拟环境(venv)3.1 基础命令3

使用Node.js制作图片上传服务的详细教程

《使用Node.js制作图片上传服务的详细教程》在现代Web应用开发中,图片上传是一项常见且重要的功能,借助Node.js强大的生态系统,我们可以轻松搭建高效的图片上传服务,本文将深入探讨如何使用No... 目录准备工作搭建 Express 服务器配置 multer 进行图片上传处理图片上传请求完整代码示例

python连接本地SQL server详细图文教程

《python连接本地SQLserver详细图文教程》在数据分析领域,经常需要从数据库中获取数据进行分析和处理,下面:本文主要介绍python连接本地SQLserver的相关资料,文中通过代码... 目录一.设置本地账号1.新建用户2.开启双重验证3,开启TCP/IP本地服务二js.python连接实例1.

Python 安装和配置flask, flask_cors的图文教程

《Python安装和配置flask,flask_cors的图文教程》:本文主要介绍Python安装和配置flask,flask_cors的图文教程,本文通过图文并茂的形式给大家介绍的非常详细,... 目录一.python安装:二,配置环境变量,三:检查Python安装和环境变量,四:安装flask和flas

Spring Security基于数据库的ABAC属性权限模型实战开发教程

《SpringSecurity基于数据库的ABAC属性权限模型实战开发教程》:本文主要介绍SpringSecurity基于数据库的ABAC属性权限模型实战开发教程,本文给大家介绍的非常详细,对大... 目录1. 前言2. 权限决策依据RBACABAC综合对比3. 数据库表结构说明4. 实战开始5. MyBA

Ubuntu中远程连接Mysql数据库的详细图文教程

《Ubuntu中远程连接Mysql数据库的详细图文教程》Ubuntu是一个以桌面应用为主的Linux发行版操作系统,这篇文章主要为大家详细介绍了Ubuntu中远程连接Mysql数据库的详细图文教程,有... 目录1、版本2、检查有没有mysql2.1 查询是否安装了Mysql包2.2 查看Mysql版本2.

Elasticsearch 在 Java 中的使用教程

《Elasticsearch在Java中的使用教程》Elasticsearch是一个分布式搜索和分析引擎,基于ApacheLucene构建,能够实现实时数据的存储、搜索、和分析,它广泛应用于全文... 目录1. Elasticsearch 简介2. 环境准备2.1 安装 Elasticsearch2.2 J

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1