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()

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/210386.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/210386.shtml
英文地址,請注明出處:http://en.pswp.cn/news/210386.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

[java]學生管理系統

一、學生類 首先創建一個學生類,定義學號姓名年齡居住地 public class Student {private String id;private String name;private String age;private String address;//構造函數public Student(String id, String name, String age, String address) {this.id i…

54.grpc實現文件上傳和下載

文章目錄 一:簡介1. 什么是grpc2. 為什么我們要用grpc 二:grpc的hello world1、 定義hello.proto文件2、生成xxx_grpc.pb.go文件3、生成xxx.pb.go結構體文件4、編寫服務代碼service.go5、編寫客戶端代碼client.go 三、服務端流式傳輸:文件下載…

AIOps、微服務和云平臺

數字景觀正在從整體轉向微服務、基于云的服務。企業和公司需要適應不斷變化的技術格局并跟上變化。系統變得越來越復雜并且不容易管理。我將嘗試解釋一些較新的架構方法、趨勢,并提供對 AIOps 的見解以及它如何幫助解決這個問題。 微服務 微服務架構正在成為最受歡…

什么是web組態?一文讀懂web組態

隨著工業4.0的到來,物聯網、大數據、人工智能等技術的融合應用,使得工業領域正在經歷一場深刻的變革。在這個過程中,web組態技術以其獨特的優勢,正在逐漸受到越來越多企業的關注和認可。那么,什么是web組態&#xff1f…

android-android源碼目錄

android源碼目錄 Android.bp art bionic bootable bootstrap.bash build build.sh compatibility cts dalvik developers development device external frameworks hardware IMAGE javaenv.sh kernel libcore libnativehelper Makefile mkcombinedroot mkimage_ab.sh mkimage.…

我的創作紀念日——一年

機緣 初心始于對技術的熱愛和分享知識的渴望。最初,我在一次練習中遇到了一些問題,通過解決這些問題并將解決方案記錄下來,我意識到分享經驗對自己和他人都非常有價值。于是,我開始在博客和社交平臺上記錄日常學習過程、撰寫技術…

uni-app 獲取PAD激光測溫方式 (uni-app安卓獲取廣播內容)

直接在onload執行下列代碼 var main plus.android.runtimeMainActivity(); //獲取activityvar context plus.android.importClass(android.content.Context); //上下文var receiver plus.android.implements(io.dcloud.feature.internal.reflect.BroadcastReceiver, {onRece…

動力未來:特斯拉 Model S 電池技術一覽

電動汽車是當今最具創新性和前景的交通工具之一,它們不僅能夠提供高效、環保的駕駛體驗,還能夠減少對化石燃料的依賴,促進可持續發展。在電動汽車領域,特斯拉 Model S 是一款引領潮流的產品,它以其豪華、強勁的性能和尖端的電池技術而聞名。本文將為您介紹特斯拉 Model S …

【springboot設計源碼】慶陽非物質文化遺產展示平臺課題背景、目的、意義、研究方法

該項目含有源碼、文檔、PPT、配套開發軟件、軟件安裝教程、項目發布教程等學習內容。 目錄 一、項目介紹: 二、文檔學習資料: 三、模塊截圖: 四、開發技術與運行環境: 五、代碼展示: 六、數據庫表截圖&#xff1…

即時通訊技術文集(第26期):實時音視頻技術合集(Part1) [共16篇]

為了更好地分類閱讀 52im.net 總計1000多篇精編文章,我將在每周三推送新的一期技術文集,本次是第26 期。 [- 1 -] 實時語音聊天中的音頻處理與編碼壓縮技術簡述 [鏈接] http://www.52im.net/thread-825-1-1.html [摘要] 在視頻或者音頻通話過程中&…

2023-12-09 LeetCode每日一題(下一個更大的數值平衡數)

2023-12-09每日一題 一、題目編號 2048. 下一個更大的數值平衡數二、題目鏈接 點擊跳轉到題目位置 三、題目描述 如果整數 x 滿足:對于每個數位 d ,這個數位 恰好 在 x 中出現 d 次。那么整數 x 就是一個 數值平衡數 。 給你一個整數 n &#xff0…

數據結構和算法專題---4、限流算法與應用

本章我們會對限流算法做個簡單介紹,包括常用的限流算法(計數器、漏桶算法、令牌桶案發、滑動窗口)的概述、實現方式、典型場景做個說明。 什么是限流算法 限流是對系統的一種保護措施。即限制流量請求的頻率(每秒處理多少個請求…

11_企業架構web服務器文件及時同步

企業架構web服務器的文件及時同步 學習目標和內容 1、能夠理解為何要服務器間文件同步 2、能夠簡單描述實現文件同步的幾種方式 3、能夠實現服務器文件實時同步的案例 一、同步文件介紹 1、服務器文件同步的必要性 根據業務發展需求,業務網站架構已經發展到以上模式…

Linux文件結構與文件權限

基于centos了解Linux文件結構 了解一下文件類型 Linux采用的一切皆文件的思想,將硬件設備、軟件等所有數據信息都以文件的形式呈現在用戶面前,這就使得我們對計算機的管理更加方便。所以本篇文章會對Linux操作系統的文件結構和文件權限進行講解。 首先…

單元測試Nunit的幾種斷言

Nunit提供了一些輔助函數用于確定好某個被測試函數是否正常工作。通常把這些函數稱為斷言 斷言是單元測試最基本的組成部分。因此,NUnit程序庫以Assert類的靜態方法的形式提供了不同形式的多種斷言 1. Assert.AreEqual:比較兩個值是否相等。用于比較數…

Qt生成動態鏈接庫并使用動態鏈接庫

項目結構 整個工程由一個主程序構成和一個模塊構成(dll)。整個工程的結構目錄如下 Define.priMyProject.proMyProject.pro.user ---bin ---MainProgrammain.cppMainProgram.proMainProgram.pro.userwidget.cppwidget.hwidget.ui ---MathDllMathDll.proMathDll.pro.userMyMath.…

Axios 攔截器實戰教程:簡單易懂

Axios 提供了一種稱為 “攔截器(interceptors)” 的功能,使我們能夠在請求或響應被發送或處理之前對它們進行全局處理。攔截器為我們提供了一種簡潔而強大的方式來轉換請求和響應、進行錯誤處理、添加認證信息等操作。在本文中,我…

Matlab 點云收縮L1中值(Weiszfeld算法)

文章目錄 一、簡介二、實現代碼三、實現效果參考資料一、簡介 對于之前的加權均值收縮方式,它存在一個很大的缺點,即容易受到噪聲的影響,因此這里我們采用另一種統計學方案:L1中值。其形式如下所示: 其中 x i x_i

MongoDB的條件操作符

本文主要介紹MongoDB的條件操作符。 目錄 MongoDB條件操作符1.比較操作符2.邏輯操作符3.元素操作符4.數組操作符5.文本搜索操作符 MongoDB條件操作符 MongoDB的條件操作符主要分為比較操作符、邏輯操作符、元素操作符、數組操作符、文本搜索操作符等幾種類型。 以下是這些操作…

拷貝實體類

文章目錄 方式一 : 方式二:(不常用) 方式一 : 將左邊的實體拷貝到右邊的實體中 import org.springframework.beans.BeanUtils; BeanUtils.copyProperties(memberAddress, resp);將右邊的實體拷貝到左邊的實體中 imp…