## Table of contents

# PointToThePlane

For Genuary Prompt 22: **Point Line Plane,** I have added code to a previous Genuary2024 entry, where

"Chaotic systems can be heard through the sound design in this **SonicPi Coded Composition.** To reinforce the chaotic system, usage of geometric and linear algebra equations were used to control the sound.

The Point to Plane and Line to Plane equations were the linear algebra components used to create the sound. Then an assortment of those return values were then integrated in the circumference equation to bring a sense of **undecided geometry**."

**Poem**

```
Points to Plane
Line not knowing to stay
Undecided
But reminded
That the path isn’t only the plane
So, Chaotic they get
Chaotic in depth
```

## Audio

IllestPreacha · PointToThePlane

## Code

**SonicPi - Point to Line Code**

```
#linear algebra - point to a plane forumla
# distance between point and
# plane is: d = |Axo + Byo + Czo + D |/√(A**2 + B**2 + C**2)
#pt_$ = variable for points
#pl_$ = variable for plane
def pointToPlane (pt_a,pt_b,pt_c, pl_a,pl_b,pl_c,pl_d)
use_random_seed (Time.now.to_i)/5
point_a = [pt_a,pt_b,pt_c]
plane_a = [pl_a,pl_b,pl_c,pl_d]
#dot product of the point and planes
dot = point_a[0]*plane_a[0] + point_a[1] * plane_a[1] + point_a[2] * plane_a[2] + plane_a[3]
#the distance of the point to plane
return plane_D = dot / Math.sqrt(plane_a[0] ** 2 + plane_a[1] ** 2 + plane_a[2] ** 2)
#puts plane_D
end
def lineToPlane(xt,yt,zt, pl_a,pl_b,pl_c,pl_d)
use_random_seed (Time.now.to_i)/4
t = 0
# line to point
point_a = [xt + t,yt * t + yt,zt * 2]
plane_a = [pl_a,pl_b,pl_c,pl_d]
#dot product of the point and planes
dot = point_a[0]*plane_a[0] + point_a[1] * plane_a[1] + point_a[2] * plane_a[2] + plane_a[3]
#the distance of the point to plane
return plane_D = dot / Math.sqrt(plane_a[0] ** 2 + plane_a[1] ** 2 + plane_a[2] ** 2)
#puts plane_D
end
#the rate of the loops are determined by the distance to the plane
#as well as the sustain length
live_loop :lineToPlaneDistance do
use_random_seed (Time.now.to_i)/2
speed = lineToPlane(dice(5),dice(9),rrand_i(1,12),dice(10),8,rrand_i(-4,4),[0,1,2,3,4].choose)
sample [:loop_perc1,:ambi_dark_woosh].choose, rate: speed + 0.1, sustain: speed, amp: dice(5)
sleep [0.5,1,1.5,2,4].choose
end
live_loop :pointToPlaneDistance do
use_random_seed (Time.now.to_i)
speed = pointToPlane(dice(3),dice(4),rrand_i(0,3),dice(10),8,rrand_i(-4,4),[0,1,2,3,4].choose)
speed2 = pointToPlane(rrand_i(0,3),5,dice(4),dice(10),rrand_i(-4,4),9,[0,1,2,3,4].tick)
sample [:loop_electric,:elec_chime].choose, rate: speed, sustain: speed2, amp: dice(5)
sleep [0.5,1,1.5,2].choose
end
live_loop :DistanceToDistance do
use_random_seed (Time.now.to_i)/3
speed = pointToPlane(dice(3),dice(4),rrand_i(0,3),dice(10),8,rrand_i(-4,4),[0,1,2,3,4].choose)
speed2 = lineToPlane(rrand_i(0,3),5,dice(4),dice(10),rrand_i(-4,4),9,[0,1,2,3,4].tick)
#undecided geometry
distToDist = speed + speed2
distXdist = speed * speed2
dist_dist = speed / speed2
#points into circle
circumference = (2 * Math::PI * ([distToDist,distXdist,dist_dist].choose)).abs
area = Math::PI * (distToDist ** 2)
play [circumference,circumference/2], decay: rrand(1,4)
sample [:ambi_drone,:elec_beep,:drum_splash_hard,:guit_em9].choose, beat_stretch: area / 80
sleep [0.5,1,1.5,2,4].choose
end
live_loop :pointing do
#random seeding based on time
use_random_seed (Time.now.to_i) /2
#pointX = the x value of the points
pointX = [dice(8)+3,dice(9)-5]
#pointY = the y value of the points
pointY = [rrand_i(-5,10),rrand_i(-10,20)]
#making the point to line using distance formula
Line_Distance = Math.sqrt((pointX[1] - pointX[0])**2 + (pointY[1] - pointY[0])**2)
#playing the sounds, the notes and pitch are based on the line made
with_fx :ping_pong do
use_synth [:piano,:prophet].choose
play Line_Distance, pitch: Line_Distance, rate: Line_Distance/2, amp: 7
end
sleep [0.25,0.5,0.75,1,1.5,2].choose
end
```