f分型小试第一节的总结

 

 

参数传递的三种方法:

1.方法

2.构造器

3.属性犹豫

 

Definition


xn+1 = sin(a yn) + c cos(a xn)


yn+1 = sin(b xn) + d cos(b yn)


where a, b, c, d are variabies that define each attractor. 

 

 

<!--EndFragment-->
package 画点;

import javax.swing.JFrame;


public class Point extends JFrame {
	public void initUI(){
	this.setSize(500,400);
	this.setVisible(true);
	
	java.awt.Graphics g = this.getGraphics();
	
	//创建我们已经实现的监听器对象
	Pointadd pa = new Pointadd(g);
	//把监听器对象,嫁给界面
	this.addMouseListener(pa);
	
	
	}
	public static void main(String[] args){
		Point pt = new Point();
		pt.initUI();
	}
	

}

 

package 画点;
import java.awt.Graphics;
import java.awt.event.MouseEvent;

//实现Mouse监听器,放开时画线
public class Pointadd implements java.awt.event.MouseListener{

	  private double a=1.5f,b=-1.8f,c=1.6f,d=0.9f,x1,y1,x2,y2;
	  private java.awt.Graphics g;//画布
	   
	  public  Pointadd(Graphics g){
		  this.g=g;
	  }
	  
	 /**
   * Invoked when a mouse button has been pressed on a component.
   */
  public void mousePressed(MouseEvent e){
  	  

  }

 public void mouseReleased(MouseEvent e){  
  for(int i=0;i<100000;i++){
	  
 	  this.x2=Math.sin(a*y1)+c*Math.cos(b*x1);
 	  this.y2=Math.sin(b*x1)+d*Math.cos(a*y1);
 	 
 	
 	int x3=(int)(x2*170)+500;
	  int y3=(int)(y2*170)+400;
	  g.drawLine(x3, y3,x3,y3);
 	x1=x2;
 	y1=y2;
 	 
 	 }
  	            
  }

  /**
   * Invoked when the mouse enters a component.
   */
  public void mouseEntered(MouseEvent e){
  	
  }

  /**
   * Invoked when the mouse button has been clicked (pressed
   * and released) on a component.
   */
  public void mouseClicked(MouseEvent e){
  	
  }
  /**
   * Invoked when the mouse exits a component.
   */
  public void mouseExited(MouseEvent e){
  	
  }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值