PlatformNode2.java 文件源码

java
阅读 15 收藏 0 点赞 0 评论 0

项目:PhET 作者:
public void updateAngle() {

            final double extent = ( endAngle - startAngle ) * 360 / 2 / Math.PI;
//            final double platformAngle = platform.getPosition() * 360 / Math.PI / 2;
            final double platformAngle = -platform.getPosition() * 360 / Math.PI / 2;
            final double angle1 = startAngle * 360 / 2 / Math.PI + platformAngle;
//            System.out.println( "platform.getPosition() = " + platform.getPosition() + ", angle=" + angle1 );
            Arc2D.Double outerArc = new Arc2D.Double( -outerRadius, -outerRadius, outerRadius * 2, outerRadius * 2, angle1, extent, Arc2D.Double.OPEN );
            Arc2D.Double outerArcRev = new Arc2D.Double( -outerRadius, -outerRadius, outerRadius * 2, outerRadius * 2, angle1 + extent, -extent, Arc2D.Double.OPEN );
            Arc2D.Double innerArc = new Arc2D.Double( -innerRadius, -innerRadius, innerRadius * 2, innerRadius * 2, startAngle * 360 / 2 / Math.PI + extent + platformAngle, -extent, Arc2D.Double.OPEN );
            Arc2D.Double innerArcRev = new Arc2D.Double( -innerRadius, -innerRadius, innerRadius * 2, innerRadius * 2, angle1, extent, Arc2D.Double.OPEN );
            GeneralPath path = toPathSegment( outerArc, innerArc );
            body.setPathTo( path );

            Arc2D.Double outerArcDepth = new Arc2D.Double( -outerRadius + edgeDX, -outerRadius + edgeDY, outerRadius * 2, outerRadius * 2, angle1, extent, Arc2D.Double.OPEN );
            Arc2D.Double innerArcDepth = new Arc2D.Double( -innerRadius + edgeDX, -innerRadius + edgeDY, innerRadius * 2, innerRadius * 2, startAngle * 360 / 2 / Math.PI + extent + platformAngle, -extent, Arc2D.Double.OPEN );

//            Shape p2 = path.createTransformedShape( AffineTransform.getTranslateInstance( edgeDX, edgeDY ) );
//            bottomPanel.setPathTo( toPathSegment( outerArcDepth, innerArcDepth ) );
            northPanel.setPathTo( toPathSegment( outerArcRev, outerArcDepth ) );
            southPanel.setPathTo( toPathSegment( innerArcRev, innerArcDepth ) );
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号