OpenSCAD 基础教程

news2024/9/20 22:30:16

OpenSCAD 基础教程

文章目录

      • OpenSCAD 基础教程
        • 1. 引言
        • 2. 安装与设置
        • 3. OpenSCAD 基本概念与语法
          • 3.1 基础形状
          • 3.2 变换操作
          • 3.4 布尔运算
          • 3.4 控制流
          • 3.5 特殊功能
        • 4. 实践案例:创建一个简单的机械部件
        • 5. 高级技巧
        • 6. 导出与3D打印
        • 7. 常见问题与解决方案
        • 8. 结语

1. 引言
  • 什么是OpenSCAD?
    • OpenSCAD是一款用于创建3D CAD模型的软件,专注于编写脚本来描述模型,而不是通过交互式界面来构建模型。
    • 它适合程序员或有编程背景的人,因为模型是通过编写代码生成的。
  • OpenSCAD的应用场景
    • 主要用于机械设计、3D打印、建筑模型和教育等领域。
2. 安装与设置
  • 安装OpenSCAD

    • 访问OpenSCAD官网 (https://www.openscad.org/downloads.html),根据你的操作系统下载相应的安装包。
    • 按照安装提示完成软件安装。
  • 界面介绍

    • 代码编辑窗口: 在这里编写和修改代码。

    • 预览窗口: 显示你编写代码生成的3D模型。

    • 控制台: 显示错误信息和调试信息。

    • 工具栏: 包含常用操作按钮,如预览、渲染、导出等。

      1

3. OpenSCAD 基本概念与语法
3.1 基础形状
  • 立方体 (cube)

    cube([width, depth, height]);
    

    创建一个指定尺寸的立方体,默认从原点出发,边长为widthdepthheight

    //创建一个长宽高各为10的正立方体。
    cube(10);
    

    2

    //创建一个长为10,高为20的立方柱。
    cube([10,10,20]);
    

    3

  • 球体 (sphere)

    sphere(r=radius);
    

    创建一个指定半径radius的球体。

    //创建一个半径为5的球体
    sphere(r = 5);
    

    4

  • 圆柱体 (cylinder)

    cylinder(h=height, r=radius);
    

    创建一个指定高度height和底面半径radius的圆柱体。

    //创建一个指定高度20和底面半径5的圆柱体
    cylinder(h = 20, r = 5);
    

    5

  • 圆锥体 (cylinder with r1 and r2)

    cylinder(h=height, r1=bottom_radius, r2=top_radius);
    

    创建一个高度为height的圆锥体或截头圆锥体,底部半径为r1,顶部半径为r2

    //创建一个高度为20的圆锥体,底部半径为5。
    cylinder(h = 20, r1 = 5, r2 = 0);
    

    6

  • 环面 (torus)

    module torus(R = 20, r = 5) 
    {
        rotate_extrude(angle = 360)
        translate([R, 0, 0])
        circle(r);
    }
    
    // 示例: 创建一个大半径为 20,小半径为 5 的环面
    torus(R = 20, r = 5);
    

    7

    使用 rotate_extrudetranslate 函数结合来创建一个环面。

    1. circle(r):
      • 创建一个半径为 r 的圆。这将成为环面截面的形状。
    2. translate([R, 0, 0]):
      • 将圆形沿着 X 轴平移 R 单位。这个平移将确定环面的大半径。
    3. rotate_extrude(angle = 360):
      • 将被平移的圆围绕 Z 轴旋转 360 度,从而生成一个环面。
  • 参数说明

    • R: 环面的大半径,即圆心到环面中心轴的距离。
    • r: 环面的小半径,即圆的半径。

    通过调整 Rr 参数,你可以生成不同大小和形状的环面。

  • 可选项

    如果你想生成部分环面,可以调整 rotate_extrudeangle 参数,例如:

    rotate_extrude(angle = 180)  // 生成半个环面
    

    这段代码会生成一个半环面。

3.2 变换操作
  • 平移 (translate)

    translate([x, y, z]) 
    {
        // 你的模型
    }
    

    平移模型至指定的x, y, z位置。

    module torus(R = 20, r = 5) 
    {
        rotate_extrude(angle = 360)
        translate([R, 0, 0])
        circle(r);
    }
    
    translate([0, 0, 0])   cube(10);
    translate([20, 0, 0])  cube([10,10,20]);
    translate([40, 0, 0])  sphere(r = 5);
    translate([60, 0, 0])  cylinder(h = 20, r = 5); 
    translate([80, 0, 0])  cylinder(h = 20, r1 = 5, r2 = 0);
    translate([120, 0, 0])  torus(R = 20, r = 5);
    

    8

  • 旋转 (rotate)

    rotate([x_angle, y_angle, z_angle]) 
    {
        // 你的模型
    }
    

    围绕x, y, z轴按指定角度旋转模型。

    module torus(R = 20, r = 5) 
    {
        rotate_extrude(angle = 360)
        translate([R, 0, 0])
        circle(r);
    }
    
    rotate([0,30,0])  translate([0, 0, 0])   cube(10);
    rotate([0,60,0]) translate([20, 0, 0])  cube([10,10,20]);
    rotate([0,90,0]) translate([40, 0, 0])  sphere(r = 5);
    rotate([0,120,0]) translate([60, 0, 0])  cylinder(h = 20, r = 5); 
    rotate([0,150,0]) translate([80, 0, 0])  cylinder(h = 20, r1 = 5, r2 = 0);
    rotate([0,180,0]) translate([120, 0, 0])  torus(R = 20, r = 5);
    

    9

  • 缩放 (scale)

    scale([x_factor, y_factor, z_factor]) 
    {
        // 你的模型
    }
    

    x, y, z方向缩放模型。

    module torus(R = 20, r = 5) 
    {
        rotate_extrude(angle = 360)
        translate([R, 0, 0])
        circle(r);
    }
    
    scale([0.5,1,1])  translate([0, 0, 0])   cube(10);
    scale([1,0.5,1]) translate([20, 0, 0])  cube([10,10,20]);
    scale([1,1,0.5]) translate([40, 0, 0])  sphere(r = 5);
    scale([2,1,1]) translate([60, 0, 0])  cylinder(h = 20, r = 5); 
    scale([1,2,1]) translate([80, 0, 0])  cylinder(h = 20, r1 = 5, r2 = 0);
    scale([1,1,2]) translate([120, 0, 0])  torus(R = 20, r = 5);
    

    10

  • 镜像 (mirror)

    mirror([x, y, z]) 
    {
        // 你的模型
    }
    

    对模型进行镜像操作。镜像平面由向量[x, y, z]确定。

    module torus(R = 20, r = 5) 
    {
        rotate_extrude(angle = 360)
        translate([R, 0, 0])
        circle(r);
    }
    
    mirror([0,0,0])  translate([0, 0, 0])   cube(10);
    mirror([1,0,0]) translate([20, 0, 0])  cube([10,10,20]);
    mirror([0,1,0]) translate([40, 0, 0])  sphere(r = 5);
    mirror([0,0,1]) translate([60, 0, 0])  cylinder(h = 20, r = 5); 
    mirror([0,1,1]) translate([80, 0, 0])  cylinder(h = 20, r1 = 5, r2 = 0);
    mirror([1,1,0]) translate([120, 0, 0])  torus(R = 20, r = 5);
    

    11

  • 线性放样 (linear_extrude)

    linear_extrude(height) 
    {
        // 2D形状
    }
    

    对2D形状进行线性拉伸生成3D模型。

    // 圆形 -> 圆柱体
    module circle3D(radius = 10, height = 5) 
    {
        cylinder(r=radius, h=height);
    }
    
    // 半圆 -> 半圆柱体
    module semiCircle3D(radius = 10, height = 5) 
    {
        translate([-radius, 0, 0])
        linear_extrude(height=height)
            intersection() 
            {
                circle(r=radius);
                square([2*radius, radius]);
            }
    }
    
    // 方形 -> 立方体
    module square3D(size = [10, 10], height = 5) 
    {
        linear_extrude(height=height)
            square(size);
    }
    
    // 三角形 -> 三棱柱
    module triangle3D(base = 10, height = 10, prismHeight = 5) 
    {
        linear_extrude(height=prismHeight)
            polygon(points=[[0,0], [base, 0], [base/2, height]]);
    }
    
    // 长方形 -> 长方体
    module rectangle3D(size = [10, 20], height = 5) 
    {
        linear_extrude(height=height)
            square(size);
    }
    
    // 菱形 -> 菱形棱柱
    module rhombus3D(diagonal1 = 15, diagonal2 = 10, height = 5) 
    {
        linear_extrude(height=height)
            polygon(points=[[0, diagonal2/2], [diagonal1/2, 0], [0, -diagonal2/2], [-diagonal1/2, 0]]);
    }
    
    // 五边形 -> 五棱柱
    module pentagon3D(side = 10, height = 5) 
    {
         // 五边形的顶点坐标
        points = 
        [
            [side * cos(0), side * sin(0)], 
            [side * cos(72), side * sin(72)], 
            [side * cos(144), side * sin(144)], 
            [side * cos(-144), side * sin(-144)], 
            [side * cos(-72), side * sin(-72)]
        ];
        
        // 生成五棱柱
        linear_extrude(height=height)
            polygon(points);
    }
    
    // 六边形 -> 六棱柱
    module hexagon3D(side = 10, height = 5) 
    {
        points = 
        [
            [side * cos(0), side * sin(0)], 
            [side * cos(60), side * sin(60)], 
            [side * cos(120), side * sin(120)], 
            [side * cos(180), side * sin(180)], 
            [side * cos(240), side * sin(240)], 
            [side * cos(300), side * sin(300)]
        ];
        
          // 生成六棱柱
        linear_extrude(height=height)
            polygon(points);
    }
    
    // 七边形 -> 七棱柱
    module heptagon3D(side = 10, height = 5) 
    {
          // 七边形的顶点坐标
        points = 
        [
            [side * cos(0), side * sin(0)], 
            [side * cos(51.43), side * sin(51.43)], 
            [side * cos(102.86), side * sin(102.86)], 
            [side * cos(154.29), side * sin(154.29)], 
            [side * cos(205.71), side * sin(205.71)], 
            [side * cos(257.14), side * sin(257.14)], 
            [side * cos(308.57), side * sin(308.57)]
        ];
        
        // 生成七棱柱
        linear_extrude(height=height)
            polygon(points);
    }
    
    // 圆锥形 -> 圆锥体
    module cone3D(radius = 10, height = 15) 
    {
        cylinder(r1=radius, r2=0, h=height);
    }
    
    // 圆柱形 -> 圆柱体
    module cylinder3D(radius = 10, height = 15) 
    {
        cylinder(r=radius, h=height);
    }
    
    // 梯形 -> 梯形棱柱
    module trapezoid3D(top_width = 15, bottom_width = 25, height = 10, prismHeight = 5) 
    {
        linear_extrude(height=prismHeight)
            polygon(points=[[0,0], [bottom_width,0], [top_width, height], [0, height]]);
    }
    
    // 平行四边形 -> 平行四边形棱柱
    module parallelogram3D(base = 20, side = 10, height = 5) 
    {
        linear_extrude(height=height)
            polygon(points=[[0,0], [base, 0], [base + side, height], [side, height]]);
    }
    
    // 金字塔形 -> 四棱锥
    module pyramid3D(base = 20, height = 10) 
    {
        polyhedron(
            points=[[0,0,0], [base,0,0], [base,base,0], [0,base,0], [base/2,base/2,height]],
            faces=[[0,1,4], [1,2,4], [2,3,4], [3,0,4], [0,1,2,3]]
        );
    }
    
    
    
    
    // 测试和展示所有形状
    module Shape3D()
    {
        translate([0, 0, 0])    circle3D(10, 5);
        translate([25, 0, 0])   semiCircle3D(10, 5);
        translate([50, 0, 0])   square3D([10, 10], 5);
        translate([75, 0, 0])   triangle3D(10, 10, 5);
        translate([100, 0, 0])  rectangle3D([10, 20], 5);
        translate([125, 0, 0])  rhombus3D(15, 10, 5);
        translate([150, 0, 0])  pentagon3D(10, 5);
        translate([175, 0, 0])  hexagon3D(10, 5);
        translate([200, 0, 0])  heptagon3D(10, 5);
        translate([225, 0, 0])  cone3D(10, 15);
        translate([250, 0, 0])  cylinder3D(10, 15);
        translate([275, 0, 0])  trapezoid3D(15, 25, 10, 5);
        translate([320, 0, 0])  parallelogram3D(20, 10, 5);
        translate([360, 0, 0])  pyramid3D(20, 10);
    }
    Shape3D();
    

    12

    自定义形状

    // 三角形
    module triangle(base = 10, height = 10) 
    {
        points = 
        [
            [0,0], 
            [base, 0],
            [base/2, height]
        ];
        
        polygon(points);
    }
    
    // 长方形
    module rectangle(size = [10, 20]) 
    {
        square(size);
    }
    
    // 菱形
    module rhombus(diagonal1 = 15, diagonal2 = 10) 
    {
        points = 
        [
            [0, diagonal2/2], 
            [diagonal1/2, 0],
            [0, -diagonal2/2],
            [-diagonal1/2, 0]
        ];
        polygon(points);
    }
    
    // 五边形
    module pentagon(side = 10) 
    {
         // 五边形的顶点坐标
        points = 
        [
            [side * cos(0), side * sin(0)], 
            [side * cos(72), side * sin(72)], 
            [side * cos(144), side * sin(144)], 
            [side * cos(-144), side * sin(-144)], 
            [side * cos(-72), side * sin(-72)]
        ];
        polygon(points);
    }
    
    // 六边形
    module hexagon(side = 10) 
    {
        points = 
        [
            [side * cos(0), side * sin(0)], 
            [side * cos(60), side * sin(60)], 
            [side * cos(120), side * sin(120)], 
            [side * cos(180), side * sin(180)], 
            [side * cos(240), side * sin(240)], 
            [side * cos(300), side * sin(300)]
        ];
        
        polygon(points);
    }
    
    // 七边形
    module heptagon(side = 10) 
    {
          // 七边形的顶点坐标
        points = 
        [
            [side * cos(0), side * sin(0)], 
            [side * cos(51.43), side * sin(51.43)], 
            [side * cos(102.86), side * sin(102.86)], 
            [side * cos(154.29), side * sin(154.29)], 
            [side * cos(205.71), side * sin(205.71)], 
            [side * cos(257.14), side * sin(257.14)], 
            [side * cos(308.57), side * sin(308.57)]
        ];
        
        polygon(points);
    }
     
    // 梯形
    module trapezoid(top_width = 15, bottom_width = 25, height = 10) 
    {
        points = 
        [
            [0,0], 
            [bottom_width,0],
            [top_width, height],
            [0, height]
        ];
        polygon(points);
    }
    
    // 平行四边形
    module parallelogram(base = 20, side = 10, height = 5) 
    {
        points =
        [
            [0,0],
            [base, 0],
            [base + side, height],
            [side, height]
        ];
        polygon(points);
    }
    
     
     
    
    // 测试和展示所有形状
    module Shape3D()
    {
        translate([0, 0, 0])  linear_extrude(height = 5) triangle(10, 10);
        translate([25, 0, 0]) linear_extrude(height = 5) rectangle([10, 20]);
        translate([50, 0, 0]) linear_extrude(height = 5) rhombus(15, 10);
        translate([75, 0, 0]) linear_extrude(height = 5) pentagon(10);
        translate([100, 0, 0]) linear_extrude(height = 5) hexagon(10);
        translate([125, 0, 0]) linear_extrude(height = 5) heptagon(10);
        translate([150, 0, 0]) linear_extrude(height = 5)  trapezoid(15, 25, 10);
        translate([200, 0, 0]) linear_extrude(height = 5)  parallelogram(20, 10);
      
    }
    Shape3D();
    

    14

  • 旋转放样 (rotate_extrude)

    rotate_extrude(angle=360) 
    {
        // 2D形状
    }
    

    通过围绕一个轴旋转2D形状生成3D模型,angle指定旋转角度。

      //创建一个方面环
      translate([0,0,0])
        rotate_extrude(angle = 360)
            translate([40, 0, 0])
            square(10);
       
      //创建一个圆面环
      translate([0,0,15])
        rotate_extrude(angle = 360)
            translate([20, 0, 0])
            circle(5);
    

    13

3.4 布尔运算
  • 联合 (union)

    union() 
    {
        // 模型1
        // 模型2
    }
    

    将多个模型合并成一个整体。

  • 差集 (difference)

    difference() 
    {
        // 模型1
        // 模型2
    }
    

    从第一个模型中减去其他模型。

  • 交集 (intersection)

    intersection() 
    {
        // 模型1
        // 模型2
    }
    

    取多个模型的交集部分。

3.4 控制流
  • 模块 (module)

    module moduleName() 
    {
        // 模型定义
    }
    moduleName();
    

    定义一个模块,以便重复使用该模型。

  • 变量与赋值 (=)

    size = 10;
    cube([size, size, size]);
    

    使用变量来存储和复用值。

  • 条件语句 (if)

    if (condition) 
    {
        // 条件为真时的模型
    } 
    else 
    {
        // 条件为假时的模型
    }
    

    根据条件生成不同的模型。

  • 循环 (for)

    for (i = [start : step : end]) 
    {
        // 根据`i`生成的模型
    }
    

    用于生成重复结构,例如排列一系列模型。

  • 生成器 (children)

    module wrapper() 
    {
        translate([x, y, z])
        children();
    }
    wrapper() 
    {
        // 子模型
    }
    

    创建一个可以处理子模块的模块。

3.5 特殊功能
  • 颜色 (color)

    color("red") 
    {
        // 模型
    }
    

    为模型添加颜色,颜色名称可用字符串或RGB值表示。

  • 透明度 (alpha)

    color([r, g, b, alpha]) 
    {
        // 模型
    }
    

    为模型设置透明度,alpha值在0到1之间。

  • 多面体 (polyhedron)

    polyhedron(points=[...], faces=[...]);
    

    使用顶点和面定义一个多面体。

  • 文本 (text)

    text("Hello", size=10, font="Arial", valign="center");
    

    生成文本,文本可以通过linear_extruderotate_extrude生成3D效果。

4. 实践案例:创建一个简单的机械部件
  • 案例描述: 创建一个带有圆孔的方块。

  • 步骤

    1. 创建一个立方体:cube([20, 20, 20]);

    2. 在立方体上钻一个圆孔:

      difference() 
      {
          cube([20, 20, 20]);
          translate([10, 10, 0])
          cylinder(h=20, r=5);
      }
      
    3. 渲染模型并查看结果。

5. 高级技巧
  • 变量与参数化设计

    • 通过变量控制模型尺寸,使模型更具灵活性。

    • 例如:

      size = 20;
      cube([size, size, size]);
      
  • 条件语句

    • 使用

      if
      

      语句来控制模型的生成:

      if (condition) 
      {
          // 生成模型A
      } 
      else 
      {
          // 生成模型B
      }
      
  • 循环

    • 使用

      for
      

      循环创建重复结构:

      for (i = [0 : 10]) 
      {
          translate([i*2, 0, 0]) cube([1, 1, 1]);
      }
      
  • 模块外部调用

  1. use 指令
    • use 用于引入外部文件中的模块和函数,但不会立即执行该文件中的代码。只会将文件中的模块和函数加载到当前文件中供使用。
  2. include 指令
    • include 也用于引入外部文件中的模块和函数,但与 use 不同,它会立即执行该文件中的所有代码。

示例用法

假设你有一个外部文件 shapes.scad,内容如下:

// shapes.scad

module hexagon3D(side = 10, height = 5)
 {
    points = 
    [
        [side * cos(0), side * sin(0)], 
        [side * cos(60), side * sin(60)], 
        [side * cos(120), side * sin(120)], 
        [side * cos(180), side * sin(180)], 
        [side * cos(240), side * sin(240)], 
        [side * cos(300), side * sin(300)]
    ];
    
    linear_extrude(height=height)
        polygon(points);
}

module square3D(size = [10, 10], height = 5)
 {
    linear_extrude(height=height)
        square(size);
}

现在,你可以在另一个 OpenSCAD 文件中使用 useinclude 指令来调用 shapes.scad 文件中的模块:

// main.scad

use <shapes.scad>;

// 调用 hexagon3D 模块
hexagon3D(side = 15, height = 10);

include

// main.scad

include <shapes.scad>;

// 调用 hexagon3D 模块
hexagon3D(side = 15, height = 10);

区别总结

  • 使用 use <file.scad> 时,只加载模块和函数,不执行 file.scad 中的其他代码。
  • 使用 include <file.scad> 时,加载并执行 file.scad 中的所有代码。
6. 导出与3D打印
  • 导出STL文件
    • 渲染模型后,通过菜单 File > Export > Export as STL 导出STL文件。
    • 该文件可以用于3D打印或进一步加工。
7. 常见问题与解决方案
  • 错误调试
    • 如何阅读和理解控制台中的错误信息。
    • 常见错误的解决方法。
  • 优化模型
    • 提升模型生成速度的技巧,如减少不必要的布尔运算、优化代码结构等。
8. 结语
  • 进一步学习资源
    • 官方文档和社区资源链接。
    • 推荐的学习路线。
  • 动手实践的重要性
    • 鼓励读者多动手实践,尝试独立完成一些项目,逐步提高对OpenSCAD的理解和应用能力。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2107702.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

langchain 《斗破苍穹》智谱 RAG 问题搜索

目录 代码 项目介绍 模型对比实验 分块方法对比 检索方法对比 结果 10条问题 15条问题 局限性 代码 https://github.com/5zjk5/prompt-engineering/tree/master 项目介绍 《斗破苍穹》小说 RAG 问答&#xff0c;爬虫爬取整部小说章节&#xff0c;并分别保存到不同的…

传统CV算法——图像特征算法之斑点检测算法

文章目录 3. 斑点检测3.1 斑点的理解3.1.1 斑点定义3.1.2 斑点检测 3.2斑点检测基本原理3.3LoG计算流程及原理1. 高斯函数2. 拉普拉斯算子3. 组合高斯和平滑4. 计算 LoG4.1. 一阶导数4.2. 二阶导数4.3. 组合二阶导数 5. LoG 的特性6.多尺度检测 3.4 DOG3.4.1 DoG 的基本原理3.4…

低通滤波函数实现

在做的项目中需要通过PWM驱动IGBT来控制负载功率&#xff0c;如果PWM频率很高&#xff0c;电流采样基本不受影响。但是IGBT的开关频率高会引起更多的开关损耗&#xff0c;所以降低了PWM频率&#xff0c;但此时电流会是接近于PWM信号的波形&#xff0c;无法准确采集。所以硬件上…

读取、写入、生成txt文本文档详解——C#学习笔记

一、4中写入文本的方式&#xff1a; //①表示清空 txt StreamWriter mytxt1 new StreamWriter("D:\\1清空.txt"); string t1 ""; mytxt1.Write(t1); mytxt1.Close(); //②表示向txt写入文本 StreamWriter mytxt2 new StreamWriter("D:…

用HTML写一个动态的的电子相册实战详细案例

效果展示&#xff1a;&#x1f447; 详细代码&#xff1a; 1、新建一个.html文件 2、然后将下面的内容复制到 动态相册.html里面 <!DOCTYPE html> <html> <head><title>图片轮播效果</title><style>.container {position: relative;wi…

Pyspark下操作dataframe方法(1)

文章目录 Pyspark dataframe创建DataFrame使用Row对象使用元组与scheam使用字典与scheam注意 agg 聚合操作alias 设置别名字段设置别名设置dataframe别名 cache 缓存checkpoint RDD持久化到外部存储coalesce 设置dataframe分区数量collect 拉去数据columns 获取dataframe列 Pys…

【如何用远程连接到ubuntu服务器上的redis】

文章目录 ubuntu上安装redis常用命令 远程连接测试在另一台PC上进行远程访问 ubuntu上安装redis Redis 5.0 被包含在默认的 Ubuntu 20.04 软件源中。想要安装它&#xff0c;以 root 或者其他 sudo 身份运行下面的命令&#xff1a; sudo apt update //更新apt sudo apt inst…

全视通精彩亮相宁夏养老服务业博览会,助力西北地区养老产业高质量发展

据悉&#xff0c;今年4月&#xff0c;宁夏被列入48个全国基本养老服务综合平台试点地区&#xff0c;是全域申报成功的8个省&#xff08;直辖市&#xff09;之一&#xff0c;也是西北唯一的入选省份。5月&#xff0c;中卫市成功入选2024年居家和社区基本养老服务提升行动项目地区…

多智能体强化学习:citylearn城市建筑能量优化和需求响应

今天分享一个用于能量优化的强化学习框架&#xff0c;citylearn 代码量非常庞大&#xff0c;我都不敢看&#xff0c;看也看不完&#xff0c;不花一定的时间难以搞懂它的原理。 CityLearn&#xff08;CL&#xff09;环境是一个类似 OpenAI Gym 的环境&#xff0c;它通过控制不…

网络安全服务基础Windows--第10节-FTP主动与被动模式

概述 将某台计算机中的⽂件通过⽹络传送到可能相距很远的另⼀台计算机中&#xff0c;是⼀项基本的⽹络应⽤&#xff0c;即⽂件传送。 ⽂件传送协议FTP &#xff08;File Transfer Protocol&#xff09;是因特⽹上使⽤得最⼴泛的⽂件传送协议。 FTP是⼀个⽼早的⽹络协议&…

图形几何-如何将凹多边形分解成若干个凸多边形

凹多边形的概念 凹多边形是指至少有一个内角大于180度的多边形。与之相对&#xff0c;凸多边形的所有内角均小于或等于180度&#xff0c;且任意两点之间的连线都完全位于多边形内部。将凹多边形分解成若干个凸多边形是计算几何中的一个重要问题。 分解原理 将凹多边形分解为凸…

Python【3】乌七八糟

目录 if __name__ "__main__ 模块名————__name__ 装饰器 参数的优化——可以接受任何函数 需要添加自定义参数——再套一层 语法糖——好甜&#xff01; 类init self if __name__ "__main__ 在Python中&#xff0c;if __name__ "__main__"…

再谈全排列

题目链接&#xff1a; . - 力扣&#xff08;LeetCode&#xff09; 每次做全排列的题目&#xff0c;我都要孕育好一阵子&#xff0c;到底怎么去思考这个问题呢&#xff1f; 首先&#xff0c;我觉得最好的方式就是画个树。 画了树之后&#xff0c;你就知道&#xff0c;这个问题&…

鸿蒙轻内核M核源码分析系列五 时间管理

往期知识点记录&#xff1a; 鸿蒙&#xff08;HarmonyOS&#xff09;应用层开发&#xff08;北向&#xff09;知识点汇总 持续更新中…… 在鸿蒙轻内核源码分析上一篇文章中&#xff0c;我们剖析了中断的源码&#xff0c;简单提到了Tick中断。本文会继续分析Tick和时间相关的源…

多所高校拟撤销地理、测绘、建筑等相关专业!网友:游了很久,发现没有岸!

近日&#xff0c;各大高校频频传来专业“下线”的消息。多所高校拟撤销地理、测绘等相关专业。对此很多网友破防了&#xff0c;表示&#xff1a;还没毕业&#xff0c;专业没了&#xff1f; 更有城乡规划的网友表示&#xff1a;自己已经成为怨种毕业生&#xff0c;游了很久&…

公司数字化转型的目的是什么?

不同行业公司&#xff0c;其数字化转型的目的也不一样。下面我列举几个行业&#xff0c;给大家讲讲其数字化转型的真正目的。 制造数字化转型 制造业来说&#xff0c;数字化转型的本质是通过新一代信息技术与制造技术的融合&#xff0c;实现以数据为核心的资源要素变革、以网络…

【8.28更新】Win10 22H2 正式版:19045.4842镜像下载!

今日系统之家小编给大家带来2024年最新的Windows10 22H2正式版系统&#xff0c;该版本系统基于微软官方Windows 10 22H2 19045.4842 64位 专业版进行离线制作与优化&#xff0c;系统安全无任何病毒残留&#xff0c;且兼容性出色&#xff0c;能完美兼容新老机型。安装后&#xf…

一大波华为“黑”正在赶来

文&#xff5c;琥珀食酒社 作者 | 积溪 不管你信不信 我都敢肯定的告诉你 又一波黑华为的浪潮 将在下周到来 因为下周二 也就是9月10号 华为将发布一款划时代的产品 华为MateXT非凡大师 三折叠屏手机 就我现在得到的情况 这款手机最大的特点 就是先进 余承东都说…

SRT协议分析以及收拉流测试

文章目录 介绍协议概述协议常用URL格式协议工作流程协议包格式数据包和控制包数据包控制包ACKNACK 开源协议栈libSRTFFmpegVLC Media PlayerSRT AllianceSRS 测试使用ffmpegsrs推流端接收端播放端srs配置 使用 libSRT发送端接收端 介绍 SRT&#xff08;Secure Reliable Transpo…

力扣: 有效的字母异位词

文章目录 需求数组map结尾 需求 给定两个字符串 s 和 t &#xff0c;编写一个函数来判断 t 是否是 s 的字母异位词。 字母异位词 是通过重新排列不同单词或短语的字母而形成的单词或短语&#xff0c;通常只使用所有原始字母一次。 示例 1: 输入: s “anagram”, t “nagaram…