Post

Replies

Boosts

Views

Activity

Reply to Different implementations for the same function
Additional Information 2: That‘s how I want to call it. protocol Surface { //Some general stuff for the intersection (not implemented yet) } struct Plane: Surface { var point: Int var normal: Int } struct Zylinder: Surface { var point: Int var vector: Int var d: Double } struct Customsurface: Surface { // not implement yet // You will be able to create any shape you want } func intersect(a: Surface, b: Surface) { print(“custom“) } func intersect(a: Plane, b: Plane) { print(“plane“) } let surface = Plane(point: 10, normal: 10) let array: [Surface] = [Plane(point: 10, normal: 10), Costumsurface()] for i in array { intersect(a: surface, b: i) } Wanted results: plane general Got results: genaral general I hope this make my goal more clear.
Oct ’22
Reply to Different implementations for the same function
Additional Information: protocol Surface { //Some general stuff for the intersection (not implemented yet) } struct Plane: Surface { var point: SIMD3 var normal: SIMD3 } struct Zylinder: Surface { var point: SIMD3 var vector: SIMD3 var d: Double } struct Customsurface: Surface { //not implement yet //You will be able to creat any shap you want } So I want a function which has more implementations, so I can short cut a plane plane intersection. This functionality should still be available, when I intersect two items of [Surface]. (Zylinder is just an additional Type which is very common.) I hope it is more clear now.
Oct ’22
Reply to Solve a set of equations
More Information I want my programm to intersect two surfaces. These surfaces are given in a prametric form. A Surface contains three mathematical functions. Those are x(u,v), y(u,v), z(u,v) . So for every u and v you can compute a point in 3D-Space. (When I set up my set of equations I above, I used s and t for the second face) Some pseudo code so you can understand the Problem better. (When wrote that I want a func with two surfaces as the input I meant a function in my code) func intersect(s1: Surface, s2: Surface) { // The lines below are a mathematical notation s1.x = s2.x s1.y = s2.y s1.z = s3.z // This created a set of three equations. (like the one I shared with you in a comment) setofequations.solve() //Now the programm has to solve this set of equations } The really tricky part is that there are more parameteres than equations, so the result are mathematical functions for the unknown insteed of values. I hope could explain my problem better.
Apr ’22