3-D Graphic and Animation

本文介绍了一个使用WPF创建的3D锥形模型,并通过旋转动画实现动态展示的例子。该模型利用了Viewport3D进行3D渲染,通过DirectionalLight进行照明,并应用了基于线性渐变的材料纹理。此外,还设置了透视相机参数并实现了角度动画。

<Window x:Class="MyWeb.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MyWeb" Height="358" Width="459" VerticalContentAlignment="Stretch">

  <Grid>

    <!-- Place a Label control at the top of the view. -->
    <Label TextBlock.TextAlignment="Center"
      FontSize="20"
      Foreground="Red"
      Content="Model: Cone" Margin="171.353333333333,9,159.353333333333,0" Height="51" VerticalAlignment="Top" />

    <DockPanel>
      <Viewbox>
        <Canvas Width="321" Height="201">

          <!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
          <Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">

            <!-- Defines the camera used to view the 3D object. -->
            <Viewport3D.Camera>
              <PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
            </Viewport3D.Camera>

            <!-- The ModelVisual3D children contain the 3D models -->
            <Viewport3D.Children>

              <!-- This ModelVisual3D defines the light cast in the scene. Without light, the 3D
                 object cannot be seen. Also, the direction of the lights affect shadowing. If desired,
                 you can create multiple lights with different colors that shine from different directions. -->
              <ModelVisual3D>
                <ModelVisual3D.Content>
                  <DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
                </ModelVisual3D.Content>
              </ModelVisual3D>
              <ModelVisual3D>
                <ModelVisual3D.Content>
                  <GeometryModel3D>

                    <!-- The geometry specifes the shape of the 3D plane. In this sample, a flat sheet is created. -->
                    <GeometryModel3D.Geometry>
                      <MeshGeometry3D
                       TriangleIndices="0,1,2 3,4,5 "
                       Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
                       TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
                       Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
                    </GeometryModel3D.Geometry>

                    <!-- The material specifies the material applied to the 3D object. In this sample a linear gradient
                       covers the surface of the 3D object.-->
                    <GeometryModel3D.Material>
                      <MaterialGroup>
                        <DiffuseMaterial>
                          <DiffuseMaterial.Brush>
                            <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                              <LinearGradientBrush.GradientStops>
                                <GradientStop Color="Yellow" Offset="0" />
                                <GradientStop Color="Red" Offset="0.25" />
                                <GradientStop Color="Blue" Offset="0.75" />
                                <GradientStop Color="LimeGreen" Offset="1" />
                              </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                          </DiffuseMaterial.Brush>
                        </DiffuseMaterial>
                      </MaterialGroup>
                    </GeometryModel3D.Material>

                    <!-- Apply a transform to the object. In this sample, a rotation transform is applied, rendering the
                       3D object rotated. -->
                    <GeometryModel3D.Transform>
                      <RotateTransform3D>
                        <RotateTransform3D.Rotation>
                          <AxisAngleRotation3D Axis="0,3,0" Angle="40" x:Name="MyAnimation"/>
                        </RotateTransform3D.Rotation>
                      </RotateTransform3D>
                    </GeometryModel3D.Transform>
                  </GeometryModel3D>
                </ModelVisual3D.Content>
              </ModelVisual3D>
            </Viewport3D.Children>

            <Viewport3D.Triggers>
              <EventTrigger RoutedEvent="Viewport3D.Loaded">
                <BeginStoryboard>
                  <Storyboard>


                    <!-- This animation animates the Angle property of the AxisAngleRotation3D
                       making the 3D object rotate from -60 degrees to 60 degrees. -->
                    <DoubleAnimation
                     Storyboard.TargetName="MyAnimation"
                     Storyboard.TargetProperty="Angle"
                     From="-60" To="60" Duration="0:0:4" AutoReverse="True"  RepeatBehavior="Forever"/>


                  </Storyboard>
                 
                </BeginStoryboard>
              </EventTrigger>
            </Viewport3D.Triggers>

          </Viewport3D>
        </Canvas>
      </Viewbox>  
    </DockPanel>
  </Grid>

</Window>
 

【复现】并_离网风光互补制氢合成氨系统容量-调度优化分析(Python代码实现)内容概要:本文围绕“并_离网风光互补制氢合成氨系统容量-调度优化分析”的主题,提供了基于Python代码实现的技术研究与复现方法。通过构建风能、太阳能互补的可再生能源系统模型,结合电解水制氢与合成氨工艺流程,对系统的容量配置与运行调度进行联合优化分析。利用优化算法求解系统在不同运行模式下的最优容量配比和调度策略,兼顾经济性、能效性和稳定性,适用于并网与离网两种场景。文中强调通过代码实践完成系统建模、约束设定、目标函数设计及求解过程,帮助读者掌握综合能源系统优化的核心方法。; 适合人群:具备一定Python编程基础和能源系统背景的研究生、科研人员及工程技术人员,尤其适合从事可再生能源、氢能、综合能源系统优化等相关领域的从业者;; 使用场景及目标:①用于学与科研中对风光制氢合成氨系统的建模与优化训练;②支撑实际项目中对多能互补系统容量规划与调度策略的设计与验证;③帮助理解优化算法在能源系统中的应用逻辑与实现路径;; 阅读建议:建议读者结合文中提供的Python代码进行逐模块调试与运行,配合文档说明深入理解模型构建细节,重点关注目标函数设计、约束条件设置及求解器调用方式,同时可对比Matlab版本实现以拓宽工具应用视野。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值