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

2023-12-09 04:12

本文主要是介绍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/472441

相关文章

Ubuntu固定虚拟机ip地址的方法教程

《Ubuntu固定虚拟机ip地址的方法教程》本文详细介绍了如何在Ubuntu虚拟机中固定IP地址,包括检查和编辑`/etc/apt/sources.list`文件、更新网络配置文件以及使用Networ... 1、由于虚拟机网络是桥接,所以ip地址会不停地变化,接下来我们就讲述ip如何固定 2、如果apt安

PyCharm 接入 DeepSeek最新完整教程

《PyCharm接入DeepSeek最新完整教程》文章介绍了DeepSeek-V3模型的性能提升以及如何在PyCharm中接入和使用DeepSeek进行代码开发,本文通过图文并茂的形式给大家介绍的... 目录DeepSeek-V3效果演示创建API Key在PyCharm中下载Continue插件配置Con

Deepseek R1模型本地化部署+API接口调用详细教程(释放AI生产力)

《DeepseekR1模型本地化部署+API接口调用详细教程(释放AI生产力)》本文介绍了本地部署DeepSeekR1模型和通过API调用将其集成到VSCode中的过程,作者详细步骤展示了如何下载和... 目录前言一、deepseek R1模型与chatGPT o1系列模型对比二、本地部署步骤1.安装oll

在不同系统间迁移Python程序的方法与教程

《在不同系统间迁移Python程序的方法与教程》本文介绍了几种将Windows上编写的Python程序迁移到Linux服务器上的方法,包括使用虚拟环境和依赖冻结、容器化技术(如Docker)、使用An... 目录使用虚拟环境和依赖冻结1. 创建虚拟环境2. 冻结依赖使用容器化技术(如 docker)1. 创

Spring Boot整合log4j2日志配置的详细教程

《SpringBoot整合log4j2日志配置的详细教程》:本文主要介绍SpringBoot项目中整合Log4j2日志框架的步骤和配置,包括常用日志框架的比较、配置参数介绍、Log4j2配置详解... 目录前言一、常用日志框架二、配置参数介绍1. 日志级别2. 输出形式3. 日志格式3.1 PatternL

MySQL8.2.0安装教程分享

《MySQL8.2.0安装教程分享》这篇文章详细介绍了如何在Windows系统上安装MySQL数据库软件,包括下载、安装、配置和设置环境变量的步骤... 目录mysql的安装图文1.python访问网址2javascript.点击3.进入Downloads向下滑动4.选择Community Server5.

CentOS系统Maven安装教程分享

《CentOS系统Maven安装教程分享》本文介绍了如何在CentOS系统中安装Maven,并提供了一个简单的实际应用案例,安装Maven需要先安装Java和设置环境变量,Maven可以自动管理项目的... 目录准备工作下载并安装Maven常见问题及解决方法实际应用案例总结Maven是一个流行的项目管理工具

本地私有化部署DeepSeek模型的详细教程

《本地私有化部署DeepSeek模型的详细教程》DeepSeek模型是一种强大的语言模型,本地私有化部署可以让用户在自己的环境中安全、高效地使用该模型,避免数据传输到外部带来的安全风险,同时也能根据自... 目录一、引言二、环境准备(一)硬件要求(二)软件要求(三)创建虚拟环境三、安装依赖库四、获取 Dee

MySql9.1.0安装详细教程(最新推荐)

《MySql9.1.0安装详细教程(最新推荐)》MySQL是一个流行的关系型数据库管理系统,支持多线程和多种数据库连接途径,能够处理上千万条记录的大型数据库,本文介绍MySql9.1.0安装详细教程,... 目录mysql介绍:一、下载 Mysql 安装文件二、Mysql 安装教程三、环境配置1.右击此电脑

在idea中使用mysql数据库超详细教程

《在idea中使用mysql数据库超详细教程》:本文主要介绍如何在IntelliJIDEA中连接MySQL数据库,并使用控制台执行SQL语句,还详细讲解了如何使用MyBatisGenerator快... 目录一、连接mysql二、使用mysql三、快速生成实体、接口、sql文件总结一、连接mysql在ID