# Untitled

unknown
java
2 years ago
2.1 kB
3
Indexable
Never
```class Solution {
public int visiblePoints(String direction, int radiusInt, int[] xs, int[] ys) {
double angle1, angle2, angle3, angle4;

if (direction.equals("D")) {
angle1 = -135;
angle2 = -90;
angle3 = -90;
angle4 = -45;
} else if (direction.equals("R")) {
angle1 = -45;
angle2 = 0;
angle3 = 0;
angle4 = 45;
} else if (direction.equals("U")) {
angle1 = 45;
angle2 = 90;
angle3 = 90;
angle4 = 135;
} else {
angle1 = 135;
angle2 = 180;
angle3 = -180;
angle4 = -135;
}

int numPoints = xs.length;
int originPoints = 0;

List<Point> points = new ArrayList<>();
for (int i = 0; i < numPoints; i++) {
int x = xs[i];
int y = ys[i];
if (x == 0 && y == 0) {
originPoints++;
} else {
}
}

int result = 0;
for (Point point: points) {
if ((point.angle >= angle1 && point.angle <= angle2) || (point.angle >= angle3 && point.angle <= angle4)) {
result++;
}
}
}

return originPoints + result;
}

return (deg * Math.PI) / 180.0;
}

static class Point {
int x, y;
double angle;
long distanceFromOrigin;

Point(int x, int y) {
this.x = x;
this.y = y;

this.angle = Math.atan2(y, x);
this.distanceFromOrigin = ((long) x) * ((long) x) + ((long) y) * ((long) y);
}
}
}
```