-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circle intersect #335
base: usage-examples
Are you sure you want to change the base?
Circle intersect #335
Changes from 18 commits
083956f
6a53854
cac3e39
ff3ab6b
9956b61
7448f80
5e8f8e8
ee3d2c9
c6a9a31
a663878
23bd119
6987ddf
4ca74bf
9783b8f
a6ca527
cfeb41e
9859666
ab217ad
e8aac3a
f7f31de
8df8874
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using SplashKitSDK; | ||
|
||
namespace CircleIntersect | ||
{ | ||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
//Read the data for Circle A | ||
SplashKit.WriteLine("X coordinate for circle A: "); | ||
int X_A = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
SplashKit.WriteLine("Y coordinate for circle A: "); | ||
int Y_A = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
SplashKit.WriteLine("Radient for circle A: "); | ||
int R_A = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
|
||
//Create circle A base on the data | ||
Circle A = SplashKit.CircleAt(X_A, Y_A, R_A); | ||
|
||
//Read the data for Circle B | ||
SplashKit.WriteLine("X coordinate for circle B: "); | ||
int X_B = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
SplashKit.WriteLine("Y coordinate for circle B: "); | ||
int Y_B = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
SplashKit.WriteLine("Radient for circle B: "); | ||
int R_B = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
|
||
//Create circle B base on the data | ||
Circle B = SplashKit.CircleAt(X_B, Y_B, R_B); | ||
|
||
//Detect if the circle intersect or not | ||
if (SplashKit.CirclesIntersect(A, B)) | ||
{ | ||
SplashKit.WriteLine("Circle Intersect!"); | ||
} | ||
else | ||
{ | ||
SplashKit.WriteLine("Circle Not Intersect!"); | ||
} | ||
|
||
//Create a window | ||
SplashKit.OpenWindow("Circle Intersect", 800, 600); | ||
SplashKit.ClearScreen(); | ||
|
||
//Draw the circle base on the data give by user | ||
SplashKit.DrawCircle(Color.Red, X_A, Y_A, R_A); | ||
SplashKit.DrawCircle(Color.Red, X_B, Y_B, R_B); | ||
|
||
SplashKit.RefreshScreen(); | ||
SplashKit.Delay(4000); | ||
SplashKit.CloseAllWindows(); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using SplashKitSDK; | ||
using static SplashKitSDK.SplashKit; | ||
|
||
//Read the data for Circle A | ||
WriteLine("X coordinate for circle A: "); | ||
int X_A = ConvertToInteger(ReadLine()); | ||
WriteLine("Y coordinate for circle A: "); | ||
int Y_A = ConvertToInteger(ReadLine()); | ||
WriteLine("Radient for circle A: "); | ||
int R_A = ConvertToInteger(ReadLine()); | ||
|
||
//Create circle A base on the data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should say "Create circle A based on the user's data" |
||
Circle A = CircleAt(X_A, Y_A, R_A); | ||
|
||
//Read the data for Circle B | ||
WriteLine("X coordinate for circle B: "); | ||
int X_B = ConvertToInteger(ReadLine()); | ||
WriteLine("Y coordinate for circle B: "); | ||
int Y_B = ConvertToInteger(ReadLine()); | ||
WriteLine("Radient for circle B: "); | ||
int R_B = ConvertToInteger(ReadLine()); | ||
|
||
//Create circle B base on the data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // Create circle B based on the user's data |
||
Circle B = CircleAt(X_B, Y_B, R_B); | ||
|
||
//Detect if the circle intersect or not | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // Detect if the circles intersect |
||
if (CirclesIntersect(A, B)) | ||
{ | ||
WriteLine("Circle Intersect!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WriteLine("The circles intersect!") |
||
} | ||
else | ||
{ | ||
WriteLine("Circle Not Intersect!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
//Create a window | ||
OpenWindow("Point At", 800, 600); | ||
ClearScreen(); | ||
|
||
//Draw the circle base on the data give by user | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // Draw the circles based on the data given by user |
||
DrawCircle(Color.Red, X_A, Y_A, R_A); | ||
DrawCircle(Color.Red, X_B, Y_B, R_B); | ||
|
||
RefreshScreen(); | ||
Delay(4000); | ||
CloseAllWindows(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "splashkit.h" | ||
|
||
int main() | ||
{ | ||
//Read the data for Circle A | ||
write_line("X coordinate for circle A: "); | ||
int X_A = convert_to_integer(read_line()); | ||
write_line("Y coordinate for circle A: "); | ||
int Y_A = convert_to_integer(read_line()); | ||
write_line("Radient for circle A: "); | ||
int R_A = convert_to_integer(read_line()); | ||
|
||
//Create circle A base on the data | ||
circle A = circle_at(X_A, Y_A, R_A); | ||
|
||
//Read the data for Circle B | ||
write_line("X coordinate for circle B: "); | ||
int X_B = convert_to_integer(read_line()); | ||
write_line("Y coordinate for circle B: "); | ||
int Y_B = convert_to_integer(read_line()); | ||
write_line("Radient for circle B: "); | ||
int R_B = convert_to_integer(read_line()); | ||
|
||
//Create circle B base on the data | ||
circle B = circle_at(X_B, Y_B , R_B); | ||
|
||
//Detect if the circle intersect or not | ||
if(circles_intersect(A, B)) | ||
{ | ||
write_line("Circle Intersect"); | ||
} | ||
else{ | ||
write_line("Circle Not Intersect"); | ||
} | ||
|
||
//Create a window | ||
open_window("Circle Intersect", 800, 600); | ||
clear_screen(); | ||
|
||
//Draw the circle base on the data give by user | ||
draw_circle(COLOR_RED, X_A, Y_A, R_A); | ||
draw_circle(COLOR_RED, X_B, Y_B, R_B); | ||
|
||
refresh_screen(); | ||
delay(4000); | ||
close_all_windows(); | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The window title in your screen shot does not match the code. Currently shows PointAt rather than Circle Intersect |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from splashkit import * | ||
|
||
# Read the data for Circle A | ||
write_line("X coordinate for circle A: ") | ||
X_A = convert_to_integer(read_line()) | ||
write_line("Y coordinate for circle A: ") | ||
Y_A = convert_to_integer(read_line()) | ||
write_line("Radient for circle A: ") | ||
R_A = convert_to_integer(read_line()) | ||
|
||
# Create circle A base on the data | ||
A = circle_at(point_at(X_A, Y_A), R_A) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could use circle_at_from_points here to match the overloaded functions used in the other files and not have to use point_at here. |
||
|
||
# Read the data for Circle B | ||
write_line("X coordinate for circle B: ") | ||
X_B = convert_to_integer(read_line()) | ||
write_line("Y coordinate for circle B: ") | ||
Y_B = convert_to_integer(read_line()) | ||
write_line("Radient for circle B: ") | ||
R_B = convert_to_integer(read_line()) | ||
|
||
# Create circle B base on the data | ||
B = circle_at(point_at(X_B, Y_B), R_B) | ||
|
||
# Detect if the circle intersect or not | ||
if (circles_intersect(A, B)): | ||
write_line("Circle Intersect") | ||
else: | ||
write_line("Circle Not Intersect") | ||
|
||
#Create a window | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your code comments are inconsistent in the sense that some have a space at the start and some don't. |
||
open_window("Circle Intersect", 800, 600) | ||
clear_screen(color_white()) | ||
|
||
#Draw the circle base on the data give by user | ||
draw_circle(color_red(), X_A, Y_A, R_A) | ||
draw_circle(color_red(), X_B, Y_B, R_B) | ||
|
||
refresh_screen() | ||
delay(4000) | ||
close_all_windows() | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#### Circles Intersection Detect System | ||
|
||
The following code shows examples of using [Circles Intersect](/api/geometry/#circles-intersect-1) to show how to detect if two circle A and B intersect or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add example to the end of the namespace "CircleIntersectExample"