0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

windows11で、sketchup6 その105

Posted at

概要

windows11に、sketchup6を入れてみた。
rubyで、3Dを書く。
練習問題やってみた。

練習問題

リサージュ図形を描け。

写真

image.png

サンプルコード

def lissa2
	model = Sketchup.active_model
	entities = model.active_entities
	group = entities.add_group
	entities = group.entities
	tbeg = 0.0 if not tbeg
	tend = 6.28318531 if not tend
	stepw = 0.0062831853 if not stepw
	formula1 = "Math::sin(6 * t)" if not formula1
	formula2 = "Math::cos(5 * t)" if not formula2
	tbeg.step(tend - stepw, stepw) do |i|
		t1 = i
		t = t1
		z1 = 0
		begin
			y1 = eval(formula1)
		rescue
			y1 = 0
		end
		begin
			x1 = eval(formula2)
		rescue
			x1 = 0
		end
		y1 = 100000000 if y1 > 100000000
		y1 = -100000000 if y1 < -100000000
		x1 = 100000000 if x1 > 100000000
		x1 = -100000000 if x1 < -100000000
		t2 = i + stepw
		t = t2
		z2 = 0
		begin
			y2 = eval(formula1)
		rescue
			y2 = 0
		end
		begin
			x2 = eval(formula2)
		rescue
			x2 = 0
		end
		y2 = 100000000 if y2 > 100000000
		y2 = -100000000 if y2 < -100000000
		x2 = 100000000 if x2 > 100000000
		x2 = -100000000 if x2 < -100000000
		pt1 = [x1.m, y1.m, z1.m]
		pt2 = [x2.m, y2.m, z2.m]
		polyline2d = entities.add_line(pt1, pt2)
	end
end





以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?